Skip to content

Toast

Status: stableAccessibility reviewedtenet-ui@0.4.0
Import
import { Toast, useToast } from 'tenet-ui';

Source: src/components/Toast/Toast.tsx

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.
childrenReactNode

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.
childrenReactNode

useToast hook

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

* required

ToastOptions

MemberTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger'Semantic tone.
titleReactNodeOptional bold lead-in line.
message *ReactNodeMain message.
durationnumberAuto-dismiss after N ms. 0 keeps it until dismissed.

ToastEntry

MemberTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'danger'Semantic tone.
titleReactNodeOptional bold lead-in line.
message *ReactNodeMain message.
durationnumberAuto-dismiss after N ms. 0 keeps it until dismissed.
id *string