Skip to content
Status
Stable
Accessibility
Reviewed
Package
tenet-ui@0.5.0
Source
Toast.tsx
Import
import { Toast, useToast } from 'tenet-ui';

When to use: brief, transient, non-blocking feedback about something that just happened (“Saved”, “Copied”, “Upload failed”). For a message anchored to content use Banner; for something that must be acknowledged use Dialog.

  • Wrap your app once in <ToastProvider> (optionally set duration and placement). Call const { toast } = useToast() anywhere beneath it.
  • Keep it short — a title plus one line of message. Toasts are glanceable, not a place for forms or long text.
  • Pick variant by meaning; danger is announced assertively (role="alert"), the rest politely (role="status"). The viewport is a labelled live region.
  • Let them auto-dismiss (default 5s); only set duration: 0 for a message the user must dismiss, and always keep the manual dismiss button.
  • Never put critical, must-act information only in a toast — it disappears. Mirror it in a Banner or inline error.
  • Don’t stack many at once; collapse repeats rather than flooding the corner.
  • ✅ toast({ variant: 'success', title: 'Saved', message: 'Your changes are live.' })
  • ✅ <ToastProvider placement="bottom-right"><App /></ToastProvider>
  • ❌ A toast as the only record of a validation error the user must fix.
  • ❌ Long, interactive content inside a toast — use a Dialog.

See also: Banner for persistent or anchored messages, Dialog for decisions, FormControl.Validation for field errors; system guideline feedback has the decision table.

1 story for Toast, open in Storybook

The full matrix (all args, controls, accessibility panel) is in Storybook.

Toast

PropTypeDefaultDescription
durationnumber5000Default auto-dismiss duration (ms) when an individual toast doesn't set one.
placement'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'bottom-rightViewport corner.
childrenReactNodeNone

ToastProvider

PropTypeDefaultDescription
durationnumber5000Default auto-dismiss duration (ms) when an individual toast doesn't set one.
placement'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'bottom-rightViewport corner.
childrenReactNodeNone

useToast hook

PropTypeDefaultDescription
toast *(options: ToastOptions) => stringNoneShow a toast; returns its id.
dismiss *(id: string) => voidNoneDismiss a toast by id.

* required

ToastOptions

MemberTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger'NoneSemantic tone.
titleReactNodeNoneOptional bold lead-in line.
message *ReactNodeNoneMain message.
durationnumberNoneAuto-dismiss after N ms. 0 keeps it until dismissed.

ToastEntry

MemberTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger'NoneSemantic tone.
titleReactNodeNoneOptional bold lead-in line.
message *ReactNodeNoneMain message.
durationnumberNoneAuto-dismiss after N ms. 0 keeps it until dismissed.
id *stringNone