Toast
import { toast, Toaster } from "@study/ui"
Result
Loading...
Live Editor
<div style={{ display: "flex", gap: 10, flexWrap: "wrap" }}> <Button onClick={() => toast("Saved")}>Neutral</Button> <Button onClick={() => toast("Link copied", "success")}>Success</Button> <Button onClick={() => toast("No connection", "danger")}>Error</Button> <Toaster /> </div>
<Toaster /> is in the app once; toast(text, tone?) works from anywhere.
When to use
- Confirmations that people do not have to read: "Saved", "Copied", "Moved to the trash".
- Nothing people have to react to – use a Notice or a dialog for that.
- At most one sentence.
Props
| Prop | Type | Default | Meaning |
|---|---|---|---|
duration | number | 2800 |
Accessibility
- The toaster is an
aria-live="polite"region: screen readers read the message without interrupting. - It stays for 2.8 seconds – long enough to read, not so long that it gets in the way.