☀️ Summer Sale: up to 40% off all templates for a limited time.Get the deal
Shadcnadmin.com

Search

Search dashboards, components and blocks

Shadcn Sonner Toast Components

An opinionated toast component for React. Every toast example sits comfortably next to Radix UI and Base UI components. Built with Shadcn UI, Tailwind CSS, Next.js and React, compatible with both Radix UI and Base UI primitives. Typescript included.

Sonner Toast 1

Sonner Toast 2

Sonner Toast 3

Sonner Toast 4

Sonner Toast 5

Sonner Toast 6

Sonner Toast 7

Sonner Toast 8

Sonner Toast 9

Sonner Toast 10

Sonner Toast 11

Sonner Toast 12

Shadcn Sonner Toast: React Toast Notification Examples

Sonner is the opinionated toast component that shadcn/ui recommends for react toast notifications, and this page presents it fully styled for the shadcn design system with Tailwind CSS. A single Toaster component mounts once in your layout, and a simple toast function fires notifications from anywhere in your app, with stacking, swipe to dismiss, and pause on hover handled for you.

Twelve toast examples are collected here for copy and paste use. They span the practical range of notification work: success, error, warning, and info toasts, toasts with descriptions and action buttons, promise-based loading toasts, custom rendered content, and position and duration configurations, all typed TypeScript for Next.js.

What you get

  • Semantic variants: Success, error, warning, and info toasts with matching icons and colors.
  • Rich toasts: Titles with descriptions for notifications that need a second line of context.
  • Action buttons: Toasts carrying an action such as undo or view, plus a cancel option.
  • Promise toasts: A single call that shows loading, then resolves to success or error with the async result.
  • Custom rendering: Fully custom toast bodies when the default layout is not enough.
  • Placement and timing: Examples of position options and duration control, including persistent toasts.

Implementation tips

  • Mount the Toaster once: Place one Toaster in your root layout and call the toast function everywhere else. Multiple toasters cause duplicate notifications.
  • Use toast.promise for async work: It ties loading, success, and error into one notification and prevents orphaned loading states.
  • Make undo the default pattern: For destructive actions, an undo action button on the toast is friendlier than a confirmation dialog for low-risk operations.
  • Keep copy short: One line for the title and at most one for the description. Anything longer belongs in a dialog or page.
  • Adjust for theme: Pass your theme to the Toaster so toasts follow light and dark mode along with the rest of the interface.

Where it fits in a dashboard

Toasts are the feedback channel for nearly every mutation in an admin app. Saving settings, deleting records, copying values, sending invites, and completing background jobs all deserve a brief confirmation that does not interrupt the user's flow, which is exactly the toast's job description.

The promise variant is particularly at home in dashboards. Wire it to a server action or API call and users see a loading toast that resolves into success or error, which covers the entire async lifecycle with one line of code.

Related components and patterns

Choosing the right feedback surface matters. Use an Alert for persistent inline messages that should stay on the page, an Alert Dialog when the user must confirm before something destructive happens, and a toast for transient confirmation after the fact.

Long-running work often pairs a toast with a Progress bar, and toasts triggered from form submissions typically follow a Button action. Complete notification flows appear in the app screens of the React dashboard templates.

Library support

Under the hood this is Sonner, the toast library by Emil Kowalski that has become the default choice in the React ecosystem for its animation quality and tiny API. The shadcn/ui Sonner docs cover the themed integration these examples build on. Sonner is not based on Radix UI or Base UI, so it adds no primitive dependencies and sits comfortably next to components from either library.

FAQs

What is Sonner and why does shadcn/ui use it?
Sonner is a standalone React toast library known for polished stacking animations and a minimal API. shadcn/ui adopted it as the recommended toast after deprecating its own toast component.
Is Sonner built on Radix UI?
No. Sonner is an independent library with no Radix UI or Base UI dependency, which means it works in any React project regardless of which primitive library the rest of your components use.
How do I show a toast for an async operation?
Use toast.promise with your promise and message config. It renders a loading toast immediately, then swaps to the success or error message when the promise settles.
Can I trigger a toast after a server action in Next.js?
Yes. Call the toast function in the client after the action resolves, or return a status from the action and fire the toast in a useEffect or the submit handler based on that result.
How do I change where toasts appear?
Set the position prop on the Toaster, for example bottom-right or top-center. The position examples on this page show the common configurations.
Can a toast require user interaction before dismissing?
You can set duration to Infinity and include an action or cancel button, but for genuine confirmations an alert dialog is the better pattern since toasts are easy to miss.