Toast
How a notice looks and that it is announced. Where and when it shows is yours.
Examples
Playground
Appearance
How strongly the tone is expressed: a tinted surface, or the tone as the surface.
Tone
What the notice means. The tint, border and icon carry it; the icon differs in shape per tone.
Content
Title only, a long description, a dismiss and an action. The icon and the close stay on the title line however many lines follow. The action is a `text` button so it reads as a link, not a second surface.
Tone by appearance
Every combination. Solid takes each tone's AA-safe fill, so white ink passes on all five.
Install
npx shadcn add @hipuku/toastUsage
import { Toast } from '@/components/haus/components/Toast'
<Toast
tone="success"
title="Palette saved"
description="3 colours added to Brand."
onClose={() => dismiss(id)}
/>API
Toast also takes its element's own attributes and forwards its ref. className lands on the root.
| Prop | Type | Description |
|---|---|---|
tone | "neutral" | "info" | "success" | "warning" | "error" | |
appearance | "subtle" | "solid" | |
titlerequired | string | Named rather than spread: it is the visible heading, not the tooltip the native title attribute would give. |
description | string | |
action | React.ReactNode | |
onClose | (() => void) |
What you provide
Toast is the notice itself. Positioning, a queue, stacking and an auto-dismiss timer are yours:
render toasts into your own container and remove them when you are done. onClose adds a dismiss
button; action adds a control on the title's row.
To play its exit, set data-state="closed" on the toast, then remove it once the animation ends.
Tones and appearances
neutral, info, success, warning and error, each subtle (the default) or solid.
Accessibility
- Announced when it appears: politely, or at once for an
error, with the title and description read as one notice. - Not focusable itself. The action and the dismiss button keep their own place in the tab order.
A toast that appears already holding its text is not reliably announced. Keep your container on the page and render toasts into it. For a notice that must not be missed, keep a record the user can open again: an announcement is not a record.