Component guideEditable source

Sonner

Transient toast notifications for application feedback.

Original component docs
On this page12 sectionsBack to top

Install one Toaster near the application root and call toast from sonner when something happens. This wrapper styles notifications; it does not send requests, persist messages, or confirm that an operation succeeded.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/sonner.json

The example also uses Button. In a real application move Toaster to your root layout. Docs previews already have a site-level host.

#Usage

"use client";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Toaster } from "@/components/ui/sonner";

export default function NotificationExample() {
  return (
    <>
      <Button onClick={() => toast("This is a local preview notification.")}>
        Show notification
      </Button>
      <Toaster closeButton />
    </>
  );
}

#API reference

Prop / partPurposeDefault
Toaster.themelight, dark, or systemTheme provider value or system
Toaster.positionStack placementSonner default
Toaster.closeButtonVisible dismissal controlSonner default
Toaster.toastOptionsShared duration and appearanceTheme styles provided
toast / toast.success / toast.errorEnqueue a messageImported from sonner

#Accessibility

Keep messages concise and avoid repeated announcements. Important errors also belong beside the failed task so they remain available after a toast disappears. Show success only after the operation succeeds. Mount only one Toaster in the application.

#Examples

#Success

Loading preview...

#Info

Loading preview...

#Warning

Loading preview...

#Error

Loading preview...

#Action

Loading preview...

#Cancel

Loading preview...

#Promise

Loading preview...