Skip to main content

Modal

Displays content in an overlay. Use to create a distraction-free experience such as a confirmation dialog or a settings panel.

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.

string

A title that describes the content of the Modal.

() => void

Method to hide an overlay.

"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.

() => void

Method to show an overlay.

"small" | "small-100" | "base" | "large" | "large-100"
Default: 'base'

Adjust the size of the Modal.

() => void

Method to toggle the visiblity of an overlay.

Learn more about registering events.

<typeof tagName> | null
<typeof tagName> | null
<typeof tagName> | null
<typeof tagName> | null

HTMLElement

The content of the Modal.

HTMLElement

The primary action to perform.

Only a Button with a variant of primary is allowed.

HTMLElement

The secondary actions to perform.

Only Button elements with a variant of secondary or auto are allowed.

Code

<>
<s-button commandFor="modal">Open</s-button>

<s-modal id="modal" heading="Details">
<s-paragraph>Displaying more details here.</s-paragraph>

<s-button slot="secondary-actions" commandFor="modal" command="--hide">
Close
</s-button>
<s-button
slot="primary-action"
variant="primary"
commandFor="modal"
command="--hide"
>
Save
</s-button>
</s-modal>
</>

Preview

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.

Was this section helpful?

  • 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
Was this section helpful?

  • 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
Was this section helpful?

  • 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"
Was this section helpful?

Component examples

Was this section helpful?

Basic modal

<>
<s-button commandFor="info-modal" command="--show">
Show product info
</s-button>

<s-modal id="info-modal" heading="Product information">
<s-text>
This product is currently out of stock and cannot be ordered.
</s-text>

<s-button slot="secondary-actions" commandFor="info-modal" command="--hide">
Close
</s-button>
</s-modal>
</>

Preview

Was this page helpful?