Skip to main content

Modal

The Modal component displays content in an overlay that requires merchant attention. Use modals to present critical information, confirmations, or focused tasks while maintaining page context.

Modals block interaction with the underlying interface until the merchant resolves the modal content.

Modals don't automatically handle state management or persistence, so manage visibility and lifecycle programmatically through events.

Use cases

  • Confirmations: Display confirmation dialogs for critical actions like refunds or data deletion.
  • Detailed views: Present information requiring focused attention, like error details or status.
  • Data collection: Collect input through forms or settings panels without navigating away.
  • Progress indicators: Show progress for long-running operations like imports or sync.

Display focused content in an overlay using a Modal component that requires merchant attention. This example shows a basic modal with header, content area, and action buttons.

Display content in a modal overlay

Display content in a modal overlay

<s-button command="--show" commandFor="modal">
Open modal
</s-button>
<s-modal id="modal" heading="Changes could not be saved">
Please check your internet connection and try again.
<s-button slot="primary-action">OK</s-button>
</s-modal>

Configure the following properties on the Modal component.

Anchor to heading
heading
string

A title that describes the content of the Modal.

string

A unique identifier for the element.

The Modal component supports slots for additional content placement within the modal. Learn more about using slots.

Anchor to primary-action
primary-action
HTMLElement

The primary action button displayed in the modal.

The tone of the button is used to define the tone of the modal.

If omitted, the modal will default to an 'info' tone, and show an 'OK' button, translated according to the user's locale.

Anchor to secondary-actions
secondary-actions
HTMLElement

The secondary action buttons displayed in the modal.

The Modal component provides event callbacks for handling user interactions. Learn more about handling events.

(event: <"s-modal">) => void

Callback when the modal is hidden.

(event: <"s-modal">) => void

Callback when the modal is shown.

  • Use for focused interactions: Reserve modals for confirmations, critical information, or tasks requiring immediate attention.
  • Write clear headings: Use concise titles that communicate the purpose or action.
  • Choose appropriate button tones: The primary-action button's tone determines the modal's overall tone. Use critical for destructive actions, success for confirmations.
  • Include secondary actions: Provide options like "Cancel" or "Go Back" to give merchants flexibility.
  • Keep content focused: Limit to essential information and actions. For complex workflows, break into multiple steps.

Multiple modals can't be displayed simultaneously—showing a new modal while another is visible may cause unexpected behavior or poor user experience.

Was this page helpful?