Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Default Toast Sonner for React

A Show Toast button that opens one line, Event has been created, with no status icon, for 4 seconds at the bottom right.

Show Toast is an outline button. The notice is one line, Event has been created, with no status icon. It uses the usual 4 seconds at the bottom right.

Use it for a neutral result, such as created, changed, or copied. If the notice should be built like the rest of the page, use Toast. In React, Base UI themes the toaster and does not write this line.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Sonner anatomy: toaster, toast, title, description, action

Usage

<>
  <Toaster />
  <Button onClick={handleShowToast} variant="outline">
    Show Toast
  </Button>
</>

FAQ

What does this toast call pass?

The button calls toast with "Event has been created" and no second argument. There is no description, action, or icon on this call, so the notice is that one line.

Does the demo render the toaster?

The demo renders its own Toaster beside the button, so it works on its own. In an app, render one Toaster near the root and call toast from anywhere.

How do I get a success or error icon on this message?

Call toast.success, toast.error, toast.warning, or toast.info with the message. Each helper sets a type, and Toaster draws the matching icon. This demo stays on plain toast, which leaves the icon slot empty.

How do I add a second line under the title?

Pass description in the second argument. That string renders under the title. This call does not pass it.

Where does this toast show up?

This call does not pass position. Toaster uses bottom-right when that prop is omitted. Set position on Toaster when every toast should share another spot.

When is the Toast component a better fit?

Use Sonner for this pattern: one toast() call and a single Toaster. Use Toast when the notice should be built from the same parts as the rest of the page. Sonner itself is React only.

API Reference

Sonner

No extra props in this demo. The rest is on the Sonner page.

Button

Sets onClick={handleShowToast} and variant="outline". The rest is on the Button page.