Modal
The modal component displays content in an overlay. Use to create a distraction-free experience such as a confirmation dialog or a settings panel.
A button triggers the modal using the commandFor attribute. Content within the modal scrolls if it exceeds available height.
Anchor to PropertiesProperties
Configure the following properties on the modal component.
- Anchor to accessibilityLabelaccessibilityLabelaccessibilityLabelstringstringrequiredrequired
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
headingprop for screen readers.- Anchor to headingheadingheadingstringstringrequiredrequired
A title that describes the content of the modal.
- Anchor to paddingpaddingpadding"base" | "none""base" | "none"Default: 'base'Default: 'base'requiredrequired
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.- Anchor to sizesizesize"small" | "small-100" | "base" | "large" | "large-100""small" | "small-100" | "base" | "large" | "large-100"Default: 'base'Default: 'base'requiredrequired
The size of the modal component, controlling its width and height. Larger sizes provide more space for content while smaller sizes are more compact.
- Anchor to showOverlayshowOverlayshowOverlay() => void() => voidrequiredrequired
A method to programmatically show the overlay.
- Anchor to hideOverlayhideOverlayhideOverlay() => void() => voidrequiredrequired
A method to programmatically hide the overlay.
- Anchor to toggleOverlaytoggleOverlaytoggleOverlay() => void() => voidrequiredrequired
A method to programmatically toggle the visibility of the overlay.
Anchor to EventsEvents
The modal component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to afterhideafterhideafterhideCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired after the modal is hidden.
- Anchor to aftershowaftershowaftershowCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired after the modal is shown.
- Anchor to hidehidehideCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired when the modal is hidden.
- Anchor to showshowshowCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired when the modal is shown.
CallbackEventListener
A function that handles events from UI components. This type represents an event listener callback that receives a `CallbackEvent` with a strongly-typed `currentTarget`. Use this for component event handlers like `click`, `focus`, `blur`, and other DOM events.
(EventListener & {
(event: CallbackEvent<T>): void;
}) | nullCallbackEvent
An event object with a strongly-typed `currentTarget` property that references the specific HTML element that triggered the event. This type extends the standard DOM `Event` interface and ensures type safety when accessing the element that fired the event.
Event & {
currentTarget: HTMLElementTagNameMap[T];
}Anchor to SlotsSlots
The modal component supports slots for additional content placement within the component. Learn more about using slots.
- Anchor to childrenchildrenchildrenHTMLElementHTMLElement
The content displayed within the modal component, typically including form fields, information, or interactive elements.
- Anchor to primary-actionprimary-actionprimary-actionHTMLElementHTMLElement
The main action button displayed in the modal footer, representing the primary action users should take.
Only accepts a single button component with a
variantofprimary. This action should align with the modal's main purpose.- Anchor to secondary-actionssecondary-actionssecondary-actionsHTMLElementHTMLElement
Additional action buttons displayed in the modal footer, providing alternative or supporting actions.
Only accepts button components with a
variantofsecondaryorauto. These are visually de-emphasized to establish clear hierarchy.
Anchor to ExamplesExamples
Anchor to Confirm a merchant actionConfirm a merchant action
Focus merchant attention on a critical decision before proceeding. This example presents a delete confirmation with cancel and confirm buttons.
Preview
html
Anchor to Show information in a modalShow information in a modal
Present information that needs merchant acknowledgment. This example displays a simple announcement with a heading and body text.
Preview
html
Provide clear choices with action buttons in the modal footer. This example pairs primary and secondary buttons for confirming or canceling.
Preview
html
Anchor to Collect input with a formCollect input with a form
Gather information without leaving the current context. This example embeds a feedback form with text inputs and a submit button.
Preview
html
Anchor to Choose modal sizeChoose modal size
Adjust modal width to match your content needs. This example demonstrates small, base, and large size variations.
Preview
html
Anchor to Display full-width contentDisplay full-width content
Display media or tables that need full-width space. This example sets the padding property to false for edge-to-edge content.
Preview
html
Anchor to Delete with async handlingDelete with async handling
Safely handle destructive operations with proper feedback. This example implements loading states, error handling, and async confirmation.
Preview
html
Anchor to Best practicesBest 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).
- Use specific action verbs: Label buttons with clear verbs like "Delete", "Save", or "Continue" rather than vague terms like "Yes", "OK", or "Submit".
- For destructive actions, explain the consequences in the modal body.
- 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.
Anchor to LimitationsLimitations
- Modals can only be opened by user interaction, not programmatically on page load.
- The modal always renders centered in the viewport and cannot be repositioned.
- Content within the modal scrolls if it exceeds the available height.