Toast API
The Toast API displays a non-disruptive message that appears at the bottom of the interface to provide quick and short feedback on the outcome of an action. This API is modeled after the Web Notification API.
Anchor to Use casesUse cases
- Success feedback: Show confirmation messages after successful save, create, or update operations.
- Error notification: Display non-blocking error messages when operations fail.
- Action buttons: Include action buttons in toasts for quick follow-up actions like undoing changes.
- Temporary alerts: Communicate brief, time-limited messages that don't require user acknowledgment.
Anchor to MethodsMethods
The Toast.show method displays a toast notification in the Shopify admin. It accepts a variety of options to customize the behavior.
- Anchor to hidehidehideToastHideToastHiderequiredrequired
Hides a Toast notification in the Shopify admin.
- Anchor to showshowshowToastShowToastShowrequiredrequired
Displays a Toast notification in the Shopify admin.
ToastHide
The `Toast.hide` method hides a Toast notification. This is not required to be called as the Toast notification will automatically hide after the `duration` has elapsed.
- id
string
voidToastShow
The `Toast.show` method displays a Toast notification in the Shopify admin. It accepts a variety of options to customize the behavior.
- message
string - opts
ToastOptions
stringToastOptions
- action
Content of an action button.
string - duration
The length of time in milliseconds the toast message should persist.
number - isError
Display an error-styled toast.
boolean - onAction
Callback fired when the action button is clicked.
() => void - onDismiss
Callback fired when the dismiss icon is clicked.
() => void