Component referenceSource owned

Sonner

An opinionated toast component for React.

Upstream reference
On this page10 sectionsBack to top
Live preview
Loading preview...

#Installation

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

#Usage

import { toast } from "sonner";

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

Mount the <Toaster /> once near the root of your app.

<Toaster />

You can then trigger toasts from any client component.

<Button
  onClick={() =>
    toast("Event has been created", {
      description: "Sunday, December 03, 2023 at 9:00 AM",
      action: {
        label: "Undo",
        onClick: () => console.log("Undo"),
      },
    })
  }
>
  Show Toast
</Button>

#Examples

#Success

Loading preview...

#Info

Loading preview...

#Warning

Loading preview...

#Error

Loading preview...

#Action

Loading preview...

#Cancel

Loading preview...

#Promise

Loading preview...