Toast
Transient confirmation that something already happened.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Transient confirmation that something already happened.
Import
import { ToastProvider, ToastViewport, Toast, ToastBody, ToastIcon, ToastContent, ToastTitle, ToastDescription, ToastAction, ToastClose } from "@ir/ui";Watch out
- Figma's
Styleaxis isappearancehere, becausestyleis a DOM prop and a component that spreads onto a div cannot own the name. Values keep Figma's: Emphasis fills with the tone, Subtle tints it. - One correction. On an Emphasis toast the file paints the dismiss ✕ with
fg/on/primary-emphasiswhile the tone icon and both text lines usefg/on/{tone}-emphasis. For three tones that happens to be the same white and nobody would notice — butfg/on/warning-emphasisis neutral-950 wherefg/on/primary-emphasisis white, so a Warning Emphasis toast in light mode draws a white ✕ on a light surface. The close follows its own toast's on-colour here. Same class as the wrong-family tokens the audit already cleared; Figma needs it too. - Raised, not acted on: the action Button instance overrides the radius to radius/lg (10) where every one of Button's 294 variants is radius/md (8), and its border is border/neutral/subtle where code's Outline is border/neutral/muted. The code Button is used as-is.
Props
Takes the props of the element it renders, and nothing of its own — styling is the component's business, not the caller's.
Do and don't
Toast what already happened; use an Alert for what still needs doing.
Don't — Put something the person must act on in a toast.
A toast leaves. Anything that disappears on a timer cannot be the only place a required action lives.
Subtle by default; Emphasis when the tone must carry across a busy screen.
Don't — Reach for Emphasis because the message feels important.
A screen where everything is saturated has no hierarchy left for the one thing that genuinely is urgent.
"Endpoint probe-04 deleted."
Don't — "Success!"
People read the toast to confirm the thing they just did. The object and the verb are the whole message.
Offer Undo in the action slot for anything destructive.
Don't — Toast a deletion and leave.
The moment right after a mistake is the only moment someone can still fix it cheaply.
Toast the operation once — "12 endpoints archived".
Don't — Fire one toast per item in a bulk operation.
Twelve stacked cards cover the screen and outlive their own usefulness, and every one is read aloud in turn.
Keep Destructive for failures and losses.
Don't — Use Destructive for a routine save that happened to be a delete.
If the loud tone is used for ordinary outcomes, nothing is left to mark the outcomes that matter.
Accessibility
- Radix Toast owns the live region, the swipe-to-dismiss and the timing. The viewport is rendered once, near the end of the document.
- The close button takes label as its aria-label; the X and the status icon are both aria-hidden.
- A toast carries an action or a close, never both — two ways out of the same message is one more decision than it is worth.
- It slides in from the edge its viewport sits on and leaves the same way; under prefers-reduced-motion it fades in and out instead. It still follows a swipe there: following a finger is not animation.
Where it is drawn
Figma — structure from figma, measurements from figma.