Toast
Short feedback after an action, shown in a corner and gone after a few seconds. Use it to confirm what happened without moving people away from their work.
Installation
Set up Camaleo once (Installation), then import what you need.
import { ToastProvider, useToast } from "@camaleo/react";One provider for the whole app
Put ToastProvider once, near the root, inside your StyleProvider. It renders the corner where toasts stack and the live region that reads them out. Two providers mean two stacks that overlap and two voices for screen readers.
import { StyleProvider, ToastProvider } from "@camaleo/react";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<StyleProvider styleName="editorial">
<ToastProvider closeLabel="Close">{children}</ToastProvider>
</StyleProvider>
</body>
</html>
);
}Then call useToast() in any component below it:
const toast = useToast();
toast.add({ title: "Preferences saved", type: "success" });Anatomy
A corner of the screen (the viewport) that stacks the toasts. Each toast has the tone's icon, a title, an optional description and action, and a close button.
Examples
Every example is a real file you can copy. They all wear the skin, mode and brand from the bar above. Each one brings its own ToastProvider only so it runs alone on this page; in your app, use the one at the root.
Tones
Click each one. The type picks the color and icon: info for progress, success when it worked, warning when it may not, danger when it failed.
With undo
Click Archive, then Undo. Offer undo for actions that are easy to reverse, instead of asking "Are you sure?" first.
Longer on screen
timeout is in milliseconds; the default is 5000. Give a longer message more time, so people can finish reading it.
Stays until closed
timeout: 0 keeps the toast until people act on it or close it. Use it when the message still matters later, like a new version to reload.
Loading, then done
Click Upload. toast.promise() shows a loading toast with a spinner, then turns it into the success or error toast when the promise settles. One toast tells the whole story.
Urgent
priority: "high" interrupts the screen reader. Keep it for problems people must know about right now, like losing the connection.
One toast for a batch
After a bulk action, sum it up in one toast: "12 contacts updated", not twelve toasts.
Read out without moving focus
Toasts are announced when the screen reader is free, and focus stays where it was, so people can keep typing.
In context
Toasts confirm actions taken elsewhere on the page. These are whole pieces of UI you can copy, in the skin you picked.
Q3 roadmap review
Marcus Lee · 4 replies · last reply on Oct 24
Design tokens
design-tokens-v2.json · 1.4 MB
Invite teammates
Anyone with this link can join Acme Studio as an editor until November 30.
Guidelines
A few words people can read at a glance: what was done and, if useful, where to find it.
It disappears on its own, and keyboard users may never reach it. Use a dialog for choices people must make.
"4 conversations archived" says it once and keeps the screen clear.
A stack of toasts covers the page, and screen readers read every one of them.
Props
0 keeps toasts until people close them.data-limited and are hidden until a newer one closes.useToast() returns add, update, close, promise and the toasts list. add takes title, description, type, timeout, priority, actionProps and onClose, and returns the toast's id. type is info, success, warning or danger; loading (a spinner) and error (same as danger) also work, and are what promise uses.
Styling hooks
Restyle it without forking: target the attributes, or set the tokens on a parent, a skin or the viewport.
Attributes
Tokens it reads
Color
Shape & size
Type & motion
This component only
Accessibility
- Toasts are read out politely, after what the screen reader is saying. With priority: "high", they interrupt.
- A toast never takes focus, so it never interrupts typing.
- The timer pauses while the pointer is over the stack or focus is inside it.
- If a toast has an action, make sure people can do the same thing somewhere else on the page, or use timeout: 0. Not everyone reaches it in 5 seconds.