Make your AI a shadcn expert

Shadcn Sonner

React toast for save confirms, undo, and async feedback. Built with TypeScript and Tailwind CSS for Next.js using Base UI — success, error, and promise states.

Sonner is a toast. You call toast() and a notice slides in, stacks, then leaves. Use it after a save, a copy, a failed request, or an undo — not when they have to read the message before they continue.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same sonner, thicker borders. The NeoBrutalism sonner is the kit if you want that look.

Usage

import { Toaster } from "@/components/ui/sonner"
import { toast } from "sonner"
toast("Kit published.")

Mount <Toaster /> once in the root layout. After that, toast() works from any client component.

Composition

Toaster

toast, toast.success, toast.error, and toast.promise come from sonner, not from the wrapper.

Types

toast(), toast.success, toast.info, toast.warning, toast.error, and toast.promise.

Scroll to load preview...

Description

Pass description for the second line — a time, a filename, or the next step.

Scroll to load preview...

Position

position on the toast, or on <Toaster /> for the default stack.

Scroll to load preview...

API

Prop

Type

toast

Prop

Type

toast.promise takes loading, success, and error. toast.dismiss(id) removes one.

Keyboard

KeyAction
Alt + TFocus the toaster and expand the stack
TabMove through toast actions
EscapeCollapse the stack when the toaster is focused

Notes

Toaster has to be mounted

toast() queues nothing until <Toaster /> is in the tree. Put it once in app/layout.tsx, next to {children}.

The wrapper already sets theme from next-themes and turns on richColors.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.