Toast
Toast notifications with an imperative `toast()` API, a stacked deck that expands on hover, swipe to dismiss and timers that pause while you read.
Customize
Installation
npx shadcn@latest add @kinetic/sonnerUsage
Render one Toaster near the root of your app, then call toast() from anywhere.
import { Toaster, toast } from "@/components/kinetic/ui/sonner";
export function SaveButton() {
return (
<>
<Toaster />
<button type="button" onClick={() => toast("Draft saved")}>
Save
</button>
</>
);
}Variants
Call toast.success, toast.info, toast.warning, toast.error or toast.loading for a matching icon and tone. Set richColors on the Toaster to tint the cards.
toast.success("Snapshot saved", { description: "All tokens synchronized." });
toast.error("Upload failed");Action
Pass action for a button inside the toast and cancel for a secondary one. Toasts with an action, error toasts and loading toasts stay until they are dismissed.
toast("Message archived", {
action: { label: "Undo", onClick: () => restore() },
});Promise
toast.promise shows a loading toast and updates the same card when the promise settles.
toast.promise(saveSettings(), {
loading: "Saving...",
success: "Settings saved",
error: "Could not save settings",
});Update and dismiss
Every call returns an id. Pass the same id to update a toast in place, and call toast.dismiss(id) to close it, or toast.dismiss() to close all.
const id = toast.loading("Publishing");
toast.success("Published", { id });Position and stack
Set position to any corner or the top and bottom center. visibleToasts limits the deck, expand keeps it open and gap sets the spacing.
<Toaster position="top-center" visibleToasts={4} expand />Motion preferences
Swipes follow the pointer 1:1 and snap back with a spring when released short. Tune the entrance with blurPx and speed. Reduced motion swaps slides for fades.
API Reference
Toaster
Zero-dependency toast region supporting stacked hover expansion, 1:1 edge-axis swipe dismissal with velocity-seeded spring snap-back, blur-slide transitions, and ARIA live announcements.
| Prop | Type | Default | Description |
|---|---|---|---|
position | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "bottom-right" | Viewport corner or edge anchoring the toast stack. |
expand / visibleToasts / duration / gap | boolean / number / number / number | false / 3 / 4000 / 12 | Controls permanent deck expansion, stack depth limit, auto-dismiss delay, and spacing. |
closeButton / richColors / blurPx / speed | boolean / boolean / number / number | true / false / 8 / 0.4 | Toggles close buttons, tinted variant surfaces, blur amount, and animation speed. |