ThiloDesign System
DV

Sonner (Toast)

shadcn/ui

Transient notifications. Auto-dismiss after 4s. Stack in the bottom-right corner.

@/components/ui/sonner

Setup

// Add once to layout.tsx:
import { Toaster } from "@/components/ui/sonner"
<Toaster richColors position="bottom-right" />

// Then in any component:
import { toast } from "sonner"
toast.success("Ticket saved")

Toaster is already added to layout.tsx — just import toast and call it.

Types — click to trigger

TypeTriggerAPINote
defaulttoast(message)Neutral — no color, no icon
successtoast.success(message)Green icon with richColors
errortoast.error(message)Red icon with richColors
warningtoast.warning(message)Orange icon with richColors
infotoast.info(message)Blue icon with richColors
with descriptiontoast(msg, { description })Secondary line below message
with actiontoast(msg, { action: { label, onClick } })Action button in toast — for Undo patterns
loading → donetoast.promise(promise, { loading, success, error })Auto transitions loading → success/error

Toaster props

PropDefaultDescription
position"bottom-right"Where toasts appear: top-left/center/right, bottom-left/center/right
richColorsfalseColored backgrounds for success/error/warning/info
expandfalseExpand stacked toasts on hover
closeButtonfalseShow X button on each toast
duration4000ms before auto-dismiss. 0 = never

Sonner vs Alert

SonnerAlert
PersistenceAuto-dismisses after 4sPermanent until resolved or dismissed
LocationOverlay — bottom-right cornerInline — part of page content
Best forAction feedback: saved, deleted, assignedForm errors, system-level warnings, SLA alerts

On this page