shadcn.io is not affiliated with official shadcn/ui
Sonner examples · Standard
Success Toast Sonner for React
A button that shows a success toast with the check icon.
A success toast confirms that an action worked. The button calls toast.success, and Toaster adds its check icon. Use it after a save, a send or an upload, and say what succeeded.
Preview
Installation
FAQ
How does this demo mark the toast as a success?
The button calls toast.success with "Your changes have been saved". That sets the type to success. Toaster then uses its success icon, a CircleCheckIcon with className="size-4" and aria-hidden.
Which options does this call pass?
Only the message. This file does not pass description, duration, action, or icon. The check icon comes from the icons map on Toaster.
How do I put a detail line under the saved message?
Pass description as the second argument to toast.success. It renders under the title. This demo leaves that argument off.
How do I add an Undo button?
Pass action with a label and an onClick. The button sits in the toast, runs onClick, and then closes the toast. This demo does not pass action.
Related
- Default Toast SonnerA button that shows a plain toast with
- Error Toast SonnerA button that shows an error toast with
- Promise Toast with Data SonnerA promise toast whose success message
- Toast with Action Button SonnerA toast with an Undo action button that
- Standard with Title AlertA neutral alert with only a title, for a
- Info Toast SonnerA button that shows an info toast with