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](https://developer.mozilla.org/en-US/docs/Web/API/Notification).
shopify.toast.show('Message sent');
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
type ToastShow = (message: string, opts?: ToastOptions) => string;
Content of an action button.
The length of time in milliseconds the toast message should persist.
Display an error-styled toast.
Callback fired when the action button is clicked.
Callback fired when the dismiss icon is clicked
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
type ToastHide = (id: string) => void;
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](https://developer.mozilla.org/en-US/docs/Web/API/Notification).
Toast with duration
shopify.toast.show('Product saved', {
duration: 5000,
});
shopify.toast.show('Product saved', {
duration: 5000,
});
Toast with action
shopify.toast.show('Product saved', {
action: 'Undo',
onAction: () => {}, // Undo logic
});
shopify.toast.show('Product saved', {
action: 'Undo',
onAction: () => {}, // Undo logic
});
Toast with dismiss callback
shopify.toast.show('Product saved', {
onDismiss: () => {}, // Dismiss logic
});
shopify.toast.show('Product saved', {
onDismiss: () => {}, // Dismiss logic
});