Skip to content

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

Free

Bottom Right Position Sonner for React

A Show Toast button that places This is a toast at the bottom right, which is also the toaster's default corner.

Show Toast is an outline button. The notice says This is a toast and appears at the bottom right. That corner is also what the toaster uses when a call omits a position.

Pass the corner on the call when this notice should name it, even if the default matches. A confirmation that stays put is an Alert. In React, Base UI does not set the position for you.

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

Where does this toast appear?

The button calls toast("This is a toast", { position: "bottom-right" }). That places this notice at the bottom right. Other toasts keep the position set on Toaster.

How do I put every toast in that spot?

Set position="bottom-right" 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?

bottom-right is also what Toaster uses when position is omitted. This call still passes it, so this notice names the corner itself. The allowed values are top-left, top-center, top-right, bottom-left, bottom-center, and bottom-right.

How do several toasts at this position stack?

Toasts along the bottom stack upward from that edge. This file only fires one toast, with that position on the call.

Does the demo render the toaster?

Yes. The demo renders its own Toaster beside the button, with no position of its own. In an app, render one Toaster near the root; a position on toast moves only that toast.

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.