Sonner

A toast notification component for displaying brief messages.

feedback
notification
toast
alert

Preview

Variants

Default toast notification.

Code

TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { Toaster } from "@/components/ui/sonner"
import { Button } from "@/components/ui/button"
import { toast } from "sonner"

export function ToastDemo() {
  return (
    <>
      <Button
        variant="outline"
        onClick={() =>
          toast("Event has been created", {
            description: "Sunday, December 21st at 4:30PM",
          })
        }
      >
        Show Toast
      </Button>
      <Toaster />
    </>
  )
}

API Reference

PropTypeDefaultDescription
positiontop-left | top-right | bottom-left | bottom-right | top-center | bottom-centerbottom-rightPosition of the toast.
closeButtonbooleanfalseWhether to show a close button.
richColorsbooleanfalseWhether to use rich colors for the toast.
expandbooleanfalseWhether to expand the toast to fill the width.