Toast
Toasts smear in from the corner, squash against their stop and land in a puff
of dust. The candy mark is a tiny face that reacts to the news, and an
onomatopoeia sticker slams in beside it. Call toast() from anywhere.
Installation
❯ npx shadcn@latest add https://yan.moe/r/toast.jsonUsage
// app/layout.tsx: mount it once
import { Toaster } from "@/components/ui/toast"
<Toaster />import { toast } from "@/components/ui/toast"
toast("Mochi-chan says hi")
toast.success("Saved!", { description: "Your snack list is safe." })
toast.error("Oh no", { description: "The parfait fell over." })toast() returns an id you can pass to toast.dismiss(id). At most four toasts are shown at once.
Accessibility
- Built on Radix Toast: toasts are announced by screen readers, pause on hover and focus, and can be swiped away.
- Press F8 to move focus to the toast region.
- With
prefers-reduced-motion: reduce, toasts appear without the smear, the dust or the sticker.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on Toaster. kawaii: smear in, dust and a sticker. subtle: fade in with sparkles. off: just appear. | "kawaii" | "subtle" | "off" | "kawaii" |
titletoast() option. The main line. | ReactNode | - |
descriptiontoast() option. A second, quieter line. | ReactNode | - |
varianttoast() option. Sets the face on the candy mark and the colours. | "default" | "success" | "error" | "default" |
durationtoast() option. Milliseconds before it leaves by itself. | number | 4000 |
sfxtoast() option. Sticker shown in kawaii mode. false hides it. | string | false | per variant |