ComponentsMarkdown
Toast
Transient status notification delivered via an imperative toast() store and <Toaster /> viewport, built on Radix Toast.
Live example
Position:
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| Toaster.position | "bottom-right" | "top-right" | "bottom-right" | Viewport corner on >=640px screens; collapses to full-width bottom-center or top-center on mobile. |
| toast({ title }) | string | — | Primary notification heading. |
| toast({ description }) | string | — | Optional secondary detail copy rendered at caption size. |
| toast({ variant }) | "neutral" | "info" | "success" | "warning" | "destructive" | "neutral" | Visual style and live-region politeness (destructive uses foreground/assertive). |
| toast({ action }) | { label: string; altText: string; onClick: () => void } | — | Optional action button; disables auto-dismiss so users never miss interactive actions. |
| toast({ duration }) | number | 5000 | Auto-dismiss delay in milliseconds (paused on hover or focus; ignored when action is set). |
Sizes and tokens
| Tier / Role | Token | Value |
|---|---|---|
| Viewport width & margin | sm:w-[26rem] / p-4 / --z-toast | 384px toast width · 16px viewport margin · full-width on <640px · z-index 50 |
| Queue capacity | MAX_VISIBLE_TOASTS | 3 visible max · FIFO queue for overflow · newest nearest edge |
| Neutral & feedback surfaces | popupSurface / alertVariants / --shadow-lg | Neutral uses popover surface; feedback variants reuse Alert subtle tints and icons |
| Motion | --duration-262 / --duration-162 | 16px edge slide + fade (262ms enter, 162ms exit); opacity-only under reduced motion |
States
Code
import { Button, Toaster, toast } from "@freshgemui/monoplinth";
export function Example() {
return (
<>
<Button
onClick={() =>
toast({
title: "Tokens exported",
description: "CSS variables written to tokens/theme.css.",
variant: "success",
action: {
label: "Undo",
altText: "Undo token export",
onClick: () => {},
},
})
}
>
Export tokens
</Button>
<Toaster position="bottom-right" />
</>
);
}Do and don't
Do: Use Toast for brief, non-blocking feedback
Confirm background saves, exports, or undoable actions without interrupting the user's current focus.
Don't: Auto-dismiss toasts with actions
Always keep action toasts open until the user acts or dismisses them (enforced automatically when action is provided).
Accessibility
destructivetoasts use Radixtype="foreground"(assertivelive region), while all other variants usetype="background"(polite).- Press
F8to jump keyboard focus to the<Toaster />viewport; timers pause automatically on hover and focus (WCAG 2.2.1). - Each toast renders at
z-toast(50) withpointer-events-auto, keeping close and action buttons clickable even when aDialogorSheetis open.
Rationale
Capping visible toasts at three with a FIFO queue prevents viewport clutter, while reusing Alert variant tints and icons keeps semantic feedback consistent across inline and floating surfaces.