ComponentsFeedback & loading
Sonner
Shared primitiveAcknowledge completed work or report an actionable failure.
@/features/ui/toast
Composition preview
Try Sonner alongside its related feedback & loading components. These examples keep all actions local.
Usage
import { toast } from "@/features/ui/toast";
toast.success("Post scheduled", {
action: { label: "View schedule", href: "/dashboard/acme/project/schedule" },
});
// Keep the shared renderer mounted once at the application root.Composition recipe. Supply application state, handlers and persistence in the owning product component. Inspect the installed source before extending its API.
API & composition
toast.success/error/info/show/dismiss; title, description, duration, operation id, action: { label, href } or { label, onClick, pendingLabel }
Usage & accessibility
Default to plain confirmations. Offer a CTA only for a useful next step: another result, tab, panel, specific draft, Undo or Retry. The shared renderer hides already visible navigation destinations and reevaluates on route changes. Redirects do not invent buttons. Queued notices have no Jobs CTA; Jobs and job administration links are excluded from all toasts. Action toasts last 10 seconds, plain confirmations 5 seconds; both pause for hover/focus. Explicit durations remain valid even when a button is hidden. Async actions stay pending until settled and remain available after failure. Use an operation id to replace queued feedback with completion. One Sonner stack at the top center on desktop and mobile, inside the active native modal. Use a white CTA followed by an inline dismiss X on the right.
Implementation contract
src/components/ui/sonner.tsx
Use named variants and semantic theme tokens. Preserve existing input values, refs, focus and cancellation behavior. Verify keyboard, narrow layouts and pending/error states when behavior changes.