Skip to content
GitHub (opens in a new tab)

Toast

A short note that floats in after an action, like Saved successfully, and goes away on its own after a few seconds, with an optional Undo.

stableMoleculecontracts/toast.json

Preview

Toast

A short note that floats in after an action, like Saved successfully, and goes away on its own after a few seconds, with an optional Undo.

Master

Info, success and warning count down 5 seconds. Danger stays until closed. Point at the toast to pause. The stack shows at most three.

Usage

Use Toast to confirm an action people just took, or to offer a quick Undo. Render it with open and onClose, and set open when the action happens. It floats at the bottom right; several stack. Status colors the icon and the bar. For messages that must stay on the page, use Alert.

Do's

  • Confirming an action people just took: saved, sent, deleted
  • Offering a quick Undo right after a change
  • Telling people someone mentioned or messaged them, with a leading Avatar and Reply or View

Don'ts

  • Errors people must fix or read later — use Alert on the page
  • Must-choose interruption — use AlertDialog
  • Long forms or multi-step work — use Modal
<Toast
  open={open}
  onClose={() => setOpen(false)}
  title="Saved successfully"
  description="Your changes have been saved."
  timestamp="Now"
  actionLabel="Undo"
  onAction={onAction}
/>

When to use

  • Confirming an action people just took: saved, sent, deleted
  • Offering a quick Undo right after a change
  • Telling people someone mentioned or messaged them, with a leading Avatar and Reply or View

When not to use

  • Errors people must fix or read later — use Alert on the page
  • Must-choose interruption — use AlertDialog
  • Long forms or multi-step work — use Modal

What an agent reads

import { Toast } from "agentic-ds-kit";
must
  • Every open Toast portals into one shared stack at the bottom right. Create the stack if missing (role=status, aria-live=polite). Newest at the bottom. No Toaster.
  • The stack shows at most three toasts. Older ones are hidden, their timers pause, and they are left out of the live region until a newer one closes.
  • info, success, and warning use role=status with aria-live=polite. danger uses role=alert (assertive).
  • The countdown pauses while the pointer is over the toast or focus is inside it.
  • Hover or focus pauses the timer so people can reach Dismiss or the action.
  • The avatar is decorative (aria-hidden) so the live region does not read the name twice; the title names the person.
  • Dismiss is a kit Button named Dismiss. The icon and the bar are decorative.
  • The action is at least 24px tall (WCAG 2.5.8).
  • It fades in unless the person prefers reduced motion.
  • built-in labels (dismiss) come from KitLabelsProvider; English by default
  • With progress the bar is a progressbar with aria-valuenow and the toast's title as its name.
  • It rises in from a light blur on the enter timing. When open turns false it stays, inert, for its exit (fade, light blur, small drop on the exit timing), then unmounts. No motion under prefers-reduced-motion
  • Actions are kit Buttons in tab order: action, secondaryAction, then Dismiss.
defaults
  • status info
  • duration 5000
  • size md
stops if
  • Do not invent ToastTitle, ToastDescription, ToastAction, ToastViewport, or Toaster. Render Toast.
  • Do not use Alert for toast feedback — Alert stays on the page
  • Do not pass action as a ReactNode slot — use actionLabel
  • Do not put more than two actions in a toast: actionLabel plus secondaryAction
  • Do not use a Dismiss action; the X Button already dismisses
  • Do not make a toast action the only way to do something important; offer it on the page too
  • Do not use avatar with status warning or danger; the status mark carries the cue there
  • Do not leave the person's name out of the title when avatar is set; the avatar is aria-hidden
  • Do not pass an image, thumbnail or custom media; use avatar or icon
  • Do not use appearance=solid mode=primary inside the toast
  • Do not use status=default, onOpenChange, density, HelpPopover, or Icon
  • Do not make duration shorter than people need to read it and reach the action
  • Do not use raw hex
  • Do not use glass, color-mix, or backdrop-blur

From contracts/toast.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
openbooleanYes—Shows the toast. Set it when the action happens.
onClosefunctionYes—() => void. Time up, Dismiss, or after the action.
titlestringYes—The bold line, like Saved successfully.
descriptionstringNo—One line under the title.
statusinfo | success | warning | dangerNoinfoColors the icon and the countdown bar. Card stays surface-card. info an i, success a check, warning a triangle, danger an alert mark. icon swaps the mark, avatar replaces it.
actionLabelstringNo—The first action under the text, like Undo.
onActionfunctionNo—() => void. Runs when the action is picked; the toast then closes. Required in practice when actionLabel is set.
secondaryActionobjectNo—A second kit Button after the action, ghost neutral sm like the first, such as View or View trash. Renders only with actionLabel; two actions at most. Runs onClick, then the toast closes. Tab order: action, secondaryAction, then Dismiss.
avatarobjectNo—The person (or organisation) the toast is about, as a kit Avatar in place of the status icon: md (32) at sm and md, lg (40) at lg. For info and success only. It is aria-hidden, so the title must name the person, like Maya Chen mentioned you. Wins over icon.
iconKitIconNo—Replaces the status icon and keeps the status color, like Upload on a file uploaded toast. Decorative (aria-hidden). Ignored when avatar is set. A curated Lucide name (PascalCase or kebab-case) renders instantly; any other Lucide name needs import "agentic-ds-kit/icons-on-demand" once. Or pass the Lucide component or an element.
durationnumber|nullNo5000How long it stays, in ms, while the bar counts down. Default 5000 for info, success and warning. danger defaults to null: it stays until closed, with no bar. null keeps any status open.
sizesm | md | lgNomdPadding and title size. sm for a short confirmation, lg for a toast with a description and an action.
progressnumberNo—0 to 100. Shows a progress bar instead of the countdown and keeps the toast open. When the work ends, clear progress and set status=success.
timestampstringNo—Preformatted time on the right of the header, like Now or 09:41.
  • Component
    →

    Alert

    Inline status banner that stays on the page.

  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.

  • Component
    →

    Modal

    Dismissible overlay for short tasks, forms, or extra detail.