---
title: Modal
description: >-
  The modal component displays content in an overlay. Use to create a
  distraction-free experience such as a confirmation dialog or a settings panel.
api_version: 2026-04
source_url:
  html: >-
    https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/overlays/modal
  md: >-
    https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/overlays/modal.md
---

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

Modals support a heading, scrollable body content, and action slots for primary and secondary buttons. For contextual content that doesn't require full focus, use [popover](https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/overlays/popover) instead.

Modals open in response to user interaction only, not programmatically on page load.

### Support Targets (24)

### Supported targets

* [customer-account.​footer.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/footer#footer-render-after-)
* [customer-account.​order-index.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-index-announcement-)
* [customer-account.​order-index.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-index-block-)
* [customer-account.​order-status.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#order-status-announcement-)
* [customer-account.​order-status.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#order-status-block-)
* [customer-account.​order-status.​cart-line-item.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#cart-line-item-render-after-)
* [customer-account.​order-status.​cart-line-list.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#cart-line-list-render-after-)
* [customer-account.​order-status.​customer-information.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#customer-information-render-after-)
* [customer-account.​order-status.​fulfillment-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/fulfillment-status#fulfillment-status-targets)
* [customer-account.​order-status.​payment-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/payments-and-returns#payments-and-returns-targets)
* [customer-account.​order-status.​return-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/payments-and-returns#return-details-render-after-)
* [customer-account.​order-status.​unfulfilled-items.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/fulfillment-status#unfulfilled-items-render-after-)
* [customer-account.​order.​action.​menu-item.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-action-menu-item-)
* [customer-account.​order.​action.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-action-)
* [customer-account.​order.​page.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/full-page#order-specific-full-page-)
* [customer-account.​page.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/full-page#customer-account-full-page-)
* [customer-account.​profile.​addresses.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-page-default-targets-)
* [customer-account.​profile.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-announcement-)
* [customer-account.​profile.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-block-)
* [customer-account.​profile.​company-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#profile-page-b2b-targets-)
* [customer-account.​profile.​company-location-addresses.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-addresses-render-after-)
* [customer-account.​profile.​company-location-payment.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-payment-render-after-)
* [customer-account.​profile.​company-location-staff.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-staff-render-after-)
* customer-account.​profile.​payment.​render-after

#### Use cases

* **Confirmation dialogs**: Display confirmation prompts for destructive or irreversible actions like canceling a subscription.
* **Policy display**: Present terms, return policies, or other important information that requires customer acknowledgment.
* **Data entry**: Collect structured input through forms displayed in a modal with save and cancel actions.
* **Detail previews**: Show detailed information or previews without navigating away from the current page.

***

## Properties

Configure the following properties on the modal component.

* **accessibilityLabel**

  **string**

  A label that describes the purpose of the modal, announced by assistive technologies. When set, screen readers will use this label instead of the `heading` to describe the modal.

* **heading**

  **string**

  A title that describes the content of the modal.

* **id**

  **string**

  A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.

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

* **size**

  **'base' | 'small' | 'small-100' | 'large' | 'large-100' | 'max'**

  **Default: 'base'**

  The size of the modal.

  * `'base'`: The default size, suitable for most use cases.
  * `'small'`: A compact modal for simple confirmations or short messages.
  * `'small-100'`: The smallest modal size.
  * `'large'`: A large modal for complex content or forms.
  * `'large-100'`: The largest fixed-size modal, providing maximum room for content.
  * `'max'`: Expands the modal to its maximum size as defined by the host application, on both the horizontal and vertical axes.

### Events

The modal component provides event callbacks for handling user interactions. Learn more about [handling events](https://shopify.dev/docs/api/polaris/using-polaris-web-components#handling-events).

* **afterhide**

  **CallbackEventListener\<typeof tagName>**

  A callback fired when the modal is hidden, after any hide animations have completed.

* **aftershow**

  **CallbackEventListener\<typeof tagName>**

  A callback fired when the modal is shown, after any show animations have completed.

* **hide**

  **CallbackEventListener\<typeof tagName>**

  A callback fired immediately after the modal is hidden.

* **show**

  **CallbackEventListener\<typeof tagName>**

  A callback fired immediately after the modal is shown.

### CallbackEventListener

A typed event listener for custom element events. The listener receives a \`CallbackEvent\` with the correct \`currentTarget\` type for the associated custom element tag.

```ts
(EventListener & {
      (event: CallbackEvent<TTagName, TEvent>): void;
    }) | null
```

### CallbackEvent

An event type that narrows the \`currentTarget\` to the specific HTML element associated with the custom element tag. This provides type-safe event handling in callback listeners.

```ts
TEvent & {
  currentTarget: HTMLElementTagNameMap[TTagName];
}
```

### Slots

The modal component supports slots for additional content placement within the component. Learn more about [using slots](https://shopify.dev/docs/api/polaris/using-polaris-web-components#slots).

* **primary-action**

  **HTMLElement**

  The main action button displayed in the modal footer, representing the primary action users should take. Only accepts a single button component.

* **secondary-actions**

  **HTMLElement**

  Additional action buttons displayed in the modal footer, providing alternative or supporting actions.

***

## Methods

The modal component exposes methods for programmatic control.

* **hideOverlay**

  **() => void**

  **required**

  A method to programmatically hide the overlay and run any associated hide animations.

***

## Examples

### Display a return policy

Present information that requires customer acknowledgment. This example shows a modal with a heading, body text, and a close button using `command="--hide"` in the `primary-action` slot.

## Display a return policy

![A modal dialog with a Return policy heading, paragraph text, and a Close button.](https://shopify.dev/assets/assets/images/templated-apis-screenshots/checkout-ui-extensions/2025-10/modal-default-B1KXExtT.png)

## html

```html
<s-button command="--show" commandFor="modal-1">View return policy</s-button>
<s-modal id="modal-1" heading="Return policy">
  <s-paragraph>We have a 30-day return policy, which means you have 30 days after receiving your item to request a return.</s-paragraph>
  <s-paragraph>To be eligible for a return, your item must be in the same condition that you received it, unworn or unused, with tags, and in its original packaging. You'll also need the receipt or proof of purchase.</s-paragraph>
  <s-button variant="primary" command="--hide" commandFor="modal-1" slot="primary-action">Close</s-button>
</s-modal>
```

### Confirm a destructive action

Pair a cancel button with a critical-toned action button to prevent accidental destructive operations. This example presents a subscription cancellation confirmation with cancel and confirm buttons in the `secondary-actions` and `primary-action` slots.

## html

```html
<s-button command="--show" commandFor="delete-modal">Cancel subscription</s-button>
<s-modal id="delete-modal" heading="Cancel subscription?">
  <s-paragraph>
    This will cancel your subscription immediately. You'll lose access to
    all benefits at the end of your current billing period.
  </s-paragraph>
  <s-button
    command="--hide"
    commandFor="delete-modal"
    slot="secondary-actions"
  >
    Keep subscription
  </s-button>
  <s-button
    variant="primary"
    tone="critical"
    command="--hide"
    commandFor="delete-modal"
    slot="primary-action"
  >
    Cancel subscription
  </s-button>
</s-modal>
```

### Collect input with a form

Gather information without leaving the current context. This example embeds a feedback form with a select field and text area inside the modal.

## html

```html
<s-button command="--show" commandFor="feedback-modal">Leave feedback</s-button>
<s-modal id="feedback-modal" heading="Share your feedback">
  <s-form>
    <s-select label="Topic">
      <s-option value="order">Order issue</s-option>
      <s-option value="product">Product question</s-option>
      <s-option value="shipping">Shipping inquiry</s-option>
    </s-select>
    <s-text-area label="Your message" rows="4"></s-text-area>
  </s-form>
  <s-button
    command="--hide"
    commandFor="feedback-modal"
    slot="secondary-actions"
  >
    Cancel
  </s-button>
  <s-button
    variant="primary"
    slot="primary-action"
  >
    Submit
  </s-button>
</s-modal>
```

***

## Best practices

* **Use for focused, specific tasks**: Modals work best when customers need to make a decision or acknowledge critical information. Don't use them for contextual tools or actions that could happen on the page directly.
* **Include a prominent call to action**: Every modal should have a clear primary action so customers know what to do next.
* **Don't nest modals**: Avoid launching one modal from another. If the workflow requires multiple steps, reconsider the design.
* **Use specific action verbs**: Label buttons with clear verbs like "Cancel subscription", "Save", or "Continue" rather than vague terms like "Yes", "OK", or "Submit".
* **Explain destructive consequences**: For destructive actions, describe what'll happen in the modal body before the customer confirms.
* **Use sparingly**: Don't create unnecessary interruptions. Modals should be a last resort for important decisions.

***
