Skip to main content

Modal Component

The Modal API allows you to display an overlay that prevents interaction with the rest of the app until dismissed.

It is used by customizing your Modal content with the Modal component and then opening it with the shopify.modal.show('modal-id') API.

The Modal component is available for use in your app. It configures a Modal to display in the Shopify Admin.

The content you provide can be simple React elements or a src prop with a URL that will be loaded.

HTMLCollection &

The content to display within a Modal. You can provide a single HTML element with children and the ui-title-bar element to configure the Modal title bar.

string

A unique identifier for the Modal

string

The URL of the content to display within a Modal. If provided, the Modal will display the content from the provided URL and any children other than the ui-title-bar and ui-save-bar elements will be ignored.

'small' | 'base' | 'large' | 'max'
Default: "base"

The size of the modal.

Before the Modal is shown, this can be changed to any of the provided values. After the Modal is shown, this can can only be changed between small, base, and large.

Examples
import {Modal, TitleBar, useAppBridge} from '@shopify/app-bridge-react';

export function MyModal() {
const shopify = useAppBridge();

return (
<>
<button onClick={() => shopify.modal.show('my-modal')}>Open Modal</button>
<Modal id="my-modal">
<p>Message</p>
<TitleBar title="Title">
<button variant="primary">Label</button>
<button onClick={() => shopify.modal.hide('my-modal')}>Label</button>
</TitleBar>
</Modal>
</>
);
}

Preview

Was this page helpful?