--- 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/modal md: https://shopify.dev/docs/api/app-home/polaris-web-components/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 * #### Code ##### jsx ```jsx <> Open Displaying more details here. Close Save ``` ##### html ```html Open Displaying more details here. Close Save ``` ## Examples Component examples ### Basic usage Basic modal Simple modal with heading and basic content for displaying information. Click the button to open the modal. Modal with actions Modal with primary and secondary action buttons. Click the button to open the confirmation modal. Modal with form fields Modal containing form fields demonstrating how to structure input fields within a modal. Click the button to open the modal. Different modal sizes Demonstrates various modal sizes for different content requirements. Click each button to see different modal sizes. Modal without padding Modal with no padding for full-width content. Click to view the modal. ### Examples * #### 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 ```