Toast
npx shadcn add @klarhimmel/toast @klarhimmel/buttonCopy for AIExamples
Basic
Tones
Action
DetailsAbout, usage, props and more
A short message that appears at the bottom, from anywhere in the app, and leaves by itself.
When to use
Use for
Confirming what already happened: saved, copied, removed with Undo.
Not for
Errors or choices that need action. Use a Banner or a Dialog.
Pairs with
Button, a list with Undo.
Preview
Each toast leaves on its own, and stays while you point at it or focus it.
Import
Import
- Files
- toast.tsx, button.tsx, in components/klarhimmel/ui/. With it: editing, theme, utils. npm: lucide-react, radix-ui.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
- Limit
- Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | 'Notifications' | |
dismissLabel | string | 'Dismiss' |
Accessibility
| Key | Does |
|---|---|
Tab | Moves to a toast's action and its close button |
Enter / Space | Runs the action or dismisses |
Escape | Dismisses the toast that has focus |
A toast stays while it is hovered or focused. Danger toasts are announced at once; the others politely.
Accessibility