UI.MD

Sonner

An opinionated toast notification system for React. Built on sonner with UI.MD theming.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/sonner.json

Usage

import { Toaster } from "@/components/ui/sonner"
import { toast } from "sonner"

Examples

Default

Mount one <Toaster /> at the root of your app, then call toast() from anywhere to fire a notification.

Positioning

Set where toasts land with position on <Toaster /> (top/bottom paired with left/center/right). Pick a cell and the code below updates to match your selection.

Toast position

position="bottom-right"

API Reference

PropTypeDefaultDescription
position"top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right""bottom-right"Where toasts are anchored on screen.
richColorsbooleanfalseEnables sonner's built-in colored success/error styling. This kit applies its own semantic tints instead.
closeButtonbooleanfalseShows a close button on each toast.
durationnumber4000How long a toast stays visible, in milliseconds.
widthnumber | string400Maximum width of the toast column, not a fixed width: toasts size to their own content and stop here. Set it on the Toaster rather than a single toast, since sonner sizes the list. Ignored below 600px, where toasts go full-bleed.