feedback
A short message that appears for a few seconds after something happens, like "Saved". Built on sonner.
npx blankui add toastBuilt on sonner. Render one <Toaster /> in the root layout, then call toast() anywhere, including outside React components.
import { Toaster, toast } from "@/components/ui/toast"
// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" data-theme="default" data-mode="light">
<body>
{children}
<Toaster />
</body>
</html>
)
}
toast("Link copied")
toast.success("Project created", { description: "Invite your team next." })
toast.error("Could not save changes", { action: { label: "Retry", onClick: save } })
toast("Message archived", { action: { label: "Undo", onClick: unarchive } })
Promise toasts:
toast.promise(saveProject(), {
loading: "Saving...",
success: "Saved",
error: "Could not save",
})
| Avoid | Instead |
|---|---|
| import { toast } from "sonner" in app code | import { toast } from "@/components/ui/toast" |
| useToast() hook (old shadcn toast) | toast() from @/components/ui/toast |
| Several <Toaster /> elements | One <Toaster /> in the root layout |
| alert('Saved') | toast.success("Saved") |
Install with the shadcn CLI: npx shadcn add https://blank.vageshwar.dev/r/toast.json