Design system/Components
Toast
A small charcoal pill that rises from the bottom of the screen, says what happened, and leaves on its own after a few seconds. For reporting an action that just happened.
In codecomponents/toast.tsx
Live example
There are three types, and only the colored dot differs: error is red, success is green, info is orange. The default is error, because most toasts in the app report something that didn't work.
Behavior
Toaster is installed once in the root layout; anywhere in the app just calls toast().
3.6sExit 0.35sbottom · center100vw − 32pxrole=status · aria-live=politeRules
Do
Say only what actually happened: "Invited, but the email wasn't sent."
Don't
A success toast when half the work failed.
Do
Show server errors with tr(data.error || "...").
Don't
Raw technical error text.
Do
For a decision, use a dialog.
Don't
A toast with a button that has to be tapped before it disappears.
import { toast } from "@/components/toast";
toast(tr("ذخیره شد."), "success");
toast(tr(data.error || "ذخیره نشد."));Sizes and timing
padding 11px 18px · radius 999px · gap 9px13px / 500 · --dark-contrast on --dark12.94 : 1 · 14.62 : 18pxerror --red · success --green · info --accentgap 8pxStacked in a columnz-index 13000.4s cubic-bezier(0.16, 1, 0.3, 1)From translateY(28px) scale(0.96)3600ms0.35s easeTo translateY(18px) scale(0.97)3950ms- The container is pointer-events: none and the toast itself is auto; a toast doesn't block clicks on the rest of the page.
- The role="status" region renders only while there's a toast; some screen readers announce a region that was created together with its text a bit late.
- A toast has no close button and doesn't stay on hover; that's why it's only for news, not for something that needs to be done.
- Hidden in print.
Do
Say the type in words too: “Couldn't save.”
Don't
“Failed” with a green dot; the dot and the sentence have to say the same thing.
Do
A short sentence that can be read in 3.6 seconds.
Don't
Two sentences with technical details; it's gone before it's read.
Related pages