--- title: Modal description: >- Displays content in an overlay. Use to create a distraction-free experience such as a confirmation dialog or a settings panel. api_name: app-home source_url: html: 'https://shopify.dev/docs/api/app-home/polaris-web-components/overlays/modal' md: >- https://shopify.dev/docs/api/app-home/polaris-web-components/overlays/modal.md --- # Modal Displays content in an overlay. Use to create a distraction-free experience such as a confirmation dialog or a settings panel. ## Properties * **accessibilityLabel** **string** A label that describes the purpose of the modal. When set, it will be announced to users using assistive technologies and will provide them with more context. This overrides the `heading` prop for screen readers. * **heading** **string** A title that describes the content of the Modal. * **hideOverlay** **() => void** Method to hide an overlay. * **padding** **"base" | "none"** **Default: 'base'** Adjust the padding around the Modal content. `base`: applies padding that is appropriate for the element. `none`: removes all padding from the element. This can be useful when elements inside the Modal need to span to the edge of the Modal. For example, a full-width image. In this case, rely on `Box` with a padding of 'base' to bring back the desired padding for the rest of the content. * **showOverlay** **() => void** Method to show an overlay. * **size** **"small" | "small-100" | "base" | "large" | "large-100"** **Default: 'base'** Adjust the size of the Modal. * **toggleOverlay** **() => void** Method to toggle the visiblity of an overlay. ## Events Learn more about [registering events](https://shopify.dev/docs/api/app-home/using-polaris-components#event-handling). * **afterhide** **CallbackEventListener\ | null** * **aftershow** **CallbackEventListener\ | null** * **hide** **CallbackEventListener\ | null** * **show** **CallbackEventListener\ | null** ### CallbackEventListener ```ts (EventListener & { (event: CallbackEvent): void; }) | null ``` ### CallbackEvent ```ts Event & { currentTarget: HTMLElementTagNameMap[T]; } ``` ## Slots * **children** **HTMLElement** The content of the Modal. * **primary-action** **HTMLElement** The primary action to perform. Only a `Button` with a variant of `primary` is allowed. * **secondary-actions** **HTMLElement** The secondary actions to perform. Only `Button` elements with a variant of `secondary` or `auto` are allowed. Examples ### Examples * #### Code ##### jsx ```jsx <> Open Displaying more details here. Close Save ``` ##### html ```html Open Displaying more details here. Close Save ``` * #### Basic modal ##### Description Simple modal with heading and basic content for displaying information. Click the button to open the modal. ##### jsx ```jsx <> Show product info This product is currently out of stock and cannot be ordered. Close ``` ##### html ```html Show product info This product is currently out of stock and cannot be ordered. Close ``` * #### Modal with actions ##### Description Modal with primary and secondary action buttons. Click the button to open the confirmation modal. ##### jsx ```jsx Delete product Are you sure you want to delete "Winter jacket"? This action cannot be undone. Delete product Cancel ``` ##### html ```html Delete product Are you sure you want to delete "Winter jacket"? This action cannot be undone. Delete product Cancel ``` * #### Modal with form fields ##### Description Modal containing form fields demonstrating how to structure input fields within a modal. Click the button to open the modal. ##### jsx ```jsx Edit customer Retail Wholesale VIP Save changes Cancel ``` ##### html ```html Edit customer Retail Wholesale VIP Save changes Cancel ``` * #### Different modal sizes ##### Description Demonstrates various modal sizes for different content requirements. Click each button to see different modal sizes. ##### jsx ```jsx Small modal Large modal {/* Small modal for quick confirmations */} Are you sure you want to proceed? Confirm Cancel {/* Large modal for detailed content */} Order #1001 Placed on March 15, 2024 Items Winter jacket - $89.99 Wool scarf - $29.99 Leather gloves - $45.99 Total: $165.97 Close ``` ##### html ```html Small modal Large modal Are you sure you want to proceed? Confirm Cancel Order #1001 Placed on March 15, 2024 Items Winter jacket - $89.99 Wool scarf - $29.99 Leather gloves - $45.99 Total: $165.97 Close ``` * #### Modal without padding ##### Description Modal with no padding for full-width content. Click to view the modal. ##### jsx ```jsx View product image Image would display here with full width Close ``` ##### html ```html View product image Image would display here with full width Close ``` ## Usage Modals are closed by default and should be triggered by a button using the `commandFor` attribute. The button's `commandFor` value should match the modal's `id`. ## Useful for * Focusing on a specific task or piece of information * Completing a flow that needs dedicated attention * Confirming a significant action before proceeding * Viewing information that's only temporarily relevant ## Best practices * Use for focused, specific tasks that require merchants to make a decision or acknowledge critical information * Include a prominent and clear call to action * Don't nest modals (avoid launching one modal from another) * Have concise and descriptive title and button text * Use thoughtfully and sparingly—don't create unnecessary interruptions * Use as a last resort for important decisions, not for contextual tools or actions that could happen on the page directly ## Content guidelines * Use 1-3 word titles in sentence case without punctuation * Keep body content to 1-2 short sentences * For destructive actions, explain the consequences * Use clear action verbs for buttons (e.g., "Delete", "Edit") instead of vague language like "Yes" or "OK"