Skip to main content

Toast

Transient confirmation of something that happened.

Guidance​

A toast confirms something that happened away from where the person is looking, such as a pipeline finishing. It sits on mm-raised with shadow-float: a status icon, one sentence, an optional action and a close button. Toasts dismiss themselves after 5 seconds; the timer pauses while the pointer is over the toast or focus is inside it. Danger toasts stay until dismissed. Escape closes the focused toast.

Put toasts in an mm-toaster, or call toast({ message }), which uses one document-level toaster. The toaster announces each message (politely, or assertively for danger), so the toast itself carries no live region.

Properties​

PropertyAttributeTypeDefaultDescription
tonetoneToastTone'info'info (default), success, warning or danger. Danger toasts never auto-dismiss.
messagemessagestring''The message, one sentence.
actionactionstring''Label for an optional action button, e.g. "View run". Fires mm-action.
durationdurationnumber5000Milliseconds before auto-dismissal. 0 keeps the toast until closed. Ignored for danger.
persistentboolean
textstringThe message as plain text, for announcements.

Methods​

MethodDescription
start()Starts the auto-dismiss timer. The toaster calls this when the toast becomes visible.
close()Closes the toast: fires mm-dismiss, then removes it from the document.

Events​

EventDetailDescription
mm-actionCustomEvent<Record<string, never>>The action button was activated. The toast then closes.
mm-dismissCustomEvent<{ reason: 'timeout' | 'close' | 'action' | 'escape' | 'api' }>The toast closed and is about to be removed.

Slots​

SlotDescription
DefaultThe message, if you need markup. Otherwise use the message attribute.

CSS parts​

PartDescription
toastThe surface.
iconThe status icon.
messageThe message.
actionThe action button.
closeThe close button.

Examples​

Every state of mm-toast in Storybook, with keyboard and screen reader tests.