View fulldotdev/ui on GitHub

Sonner

Toast notifications with Sonner, themed with the site tokens.

Installation

npx shadcn@latest add @fulldev/sonner

Add the Toaster to the root layout:

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

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <main>{children}</main>
        <Toaster />
      </body>
    </html>
  )
}

Usage

import { toast } from "sonner"
toast("Event has been created", {
  description: "Sunday, December 3 at 9:00 AM",
  action: { label: "Undo", onClick: () => toast("Event removed") },
})

toast.success, toast.info, toast.warning, toast.error, toast.loading and toast.promise set the type.

shadcn/ui documents Base UI notifications under Toast, not Sonner. This page covers the Sonner wrapper that several official examples, such as the Drawer demo, call.

API Reference

Source: react/src/components/ui/sonner.tsx

See the Sonner documentation for all options.