shadcn.io is not affiliated with official shadcn/ui
Sonner examples · Position
Top Center Position Sonner for React
A button that shows a toast in the top center of the screen.
Top center is where people look first, so keep it for notices they mustn't miss. This toast passes position: "top-center" on the call, so only this toast moves there.
Preview
Installation
FAQ
Where does this toast appear?
The button calls toast("This is a toast", { position: "top-center" }). That places this notice at the top center. Other toasts keep the position set on Toaster.
How do I put every toast in that spot?
Set position="top-center" on Toaster. This demo sets position on the one call, which is how a single notice lands somewhere the others do not.
Does the position change the message?
No. The message is the string "This is a toast". This call passes no description, icon, action, or duration.
What if I leave position off the call?
Omit position and Toaster uses bottom-right. This call passes top-center so only this notice moves. The allowed values are top-left, top-center, top-right, bottom-left, bottom-center, and bottom-right.
Related
- Top Left Position SonnerA button that shows a toast in the
- Bottom Right Position SonnerA button that shows a toast in the
- Error with Title AlertA destructive alert with only a title
- Toast with Custom Duration SonnerA toast that stays on screen for 10
- Warning with Title AlertA warning alert with only a title, for a
- Bottom Center Position SonnerA button that shows a toast in the bottom