Skip to main content

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.

position="bottom-right"·expand:false

Customize

Blur (px)8
Speed0.4

Installation

npx shadcn@latest add @kinetic/sonner

Usage

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.

PropTypeDefaultDescription
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 / gapboolean / number / number / numberfalse / 3 / 4000 / 12Controls permanent deck expansion, stack depth limit, auto-dismiss delay, and spacing.
closeButton / richColors / blurPx / speedboolean / boolean / number / numbertrue / false / 8 / 0.4Toggles close buttons, tinted variant surfaces, blur amount, and animation speed.

Notes

Mount <Toaster /> once near your layout or page root inside ThemeProvider, and import toast directly from 'sonner'. This file exports only Toaster.