A notification that floats in a corner and leaves by itself: tinted icon or avatar, title, a line of text and up to two buttons.
Default
Wrap the area in ToastProvider once, then call toast() from useToast(); each button fires one tone. A 3px bar counts down and pauses while you hover.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add toastBrings the 2 files it builds on (button.tsx, glyph.tsx). The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/toast.tsx.
import { Toast, ToastProvider, useToast } from "@/design-system/components/toast";Usage
const { toast } = useToast();
toast({ title: "Changes saved", description: "Your workspace settings were updated.", tone: "success" });Examples
States
Each tone brings its icon and colours: info, success, error, warning and neutral.
New version available
Refresh to start using the latest updates.
Changes saved
Your workspace settings have been updated.
Upload failed
Logo concepts v3.fig is over 50 MB. Try a smaller file.
Storage almost full
You've used 90% of your workspace files.
Avatar and timestamp
Replace the icon with a person for activity: comments, mentions, approvals.
Sita Rai
2 mins ago
I've finished adding my notes to Logo v3. Happy to review whenever you're ready!
With actions
Up to two small buttons. Clicking either also closes the notification.
With a description
A second line under the title for what happened and what to do.
Position
position on ToastProvider anchors the stack to a corner or the centre of the top or bottom edge.
When to use
Use it when
- Confirming an action: saved, copied, archived (with Undo)
- Activity from a person: a comment, a mention, an approval (with avatar)
Rules
- Wrap the app once in ToastProvider; call toast() from useToast()
- Keep the title under ~6 words; put the detail in description
- At most two actions: the main one is primary and comes last
- Use duration: 0 only when it needs an answer; it then stays until closed
- Rises in over 300ms ease-smooth (animate-toast-in); reduced motion fades
Properties
Toast
| Prop | Type | Default |
|---|---|---|
title * | string | – |
description | ReactNode | – |
tone | "error" | "warning" | "success" | "info" | "neutral" | "neutral" |
icon | ReactNode | – |
avatar | ReactNode | – |
timestamp | string | – |
action | { label: string; onClick: () => void } | – |
secondaryAction | { label: string; onClick: () => void } | – |
onClose | () => void | – |
countdown | number | – |
paused | boolean | false |
role | "status" | "alert" | "group" | – |
className | string | – |
ToastProvider
| Prop | Type | Default |
|---|---|---|
children * | ReactNode | – |
position | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "bottom-right" |
toast() options
| Prop | Type | Default |
|---|---|---|
title * | string | – |
description | ReactNode | – |
tone | "error" | "warning" | "success" | "info" | "neutral" | "neutral" |
icon | ReactNode | – |
avatar | ReactNode | – |
timestamp | string | – |
action | { label: string; onClick: () => void } | – |
secondaryAction | { label: string; onClick: () => void } | – |
duration | number | 5000 |
* required
Accessibility
- Polite live region; errors use role=alert when shown on their own
- The countdown pauses on hover or focus; the default is 5 seconds
- The close button is labelled Dismiss