shadcn.io is not affiliated with official shadcn/ui
Sonner examples · Interactive
Non-Dismissible Toast Sonner for React
A toast that can't be swiped away and closes on its own after 5 seconds.
Some notices should stay up for their whole time. This toast passes dismissible: false, so a swipe can't close it, and duration: 5000, so it still closes itself after 5 seconds. Use it sparingly: a message people must act on is a dialog.
Preview
Installation
FAQ
What does this toast pass?
toast is called with "This toast cannot be dismissed", dismissible: false, and duration: 5000. The 5000 is milliseconds, so the notice lasts 5 seconds.
Can I swipe this toast away?
No. dismissible: false makes the pointer handlers return before a swipe can close it. The duration still removes the toast after 5 seconds.
Does this hide the close button?
This call does not set closeButton. That option is separate, on the toast or on Toaster, and this demo sets neither. If a close button is shown, dismissible: false makes its click do nothing.
Is this the same as a loading toast?
No. toast.loading skips the timer because its type is loading. This demo is a plain toast with a finite duration, so it still closes itself.
Related
- Toast with Action Button SonnerA toast with an Undo action button that
- Toast with Action and Cancel SonnerA toast with a Delete action and a Cancel
- Default Toast SonnerA button that shows a plain toast with
- Toast with Cancel Button SonnerA toast with a Cancel button that closes
- Toast with Custom Duration SonnerA toast that stays on screen for 10
- Toast with Custom Icon SonnerA toast with its own check icon in place