Toast

A notification component that displays brief messages to users.

feedback
notification
alert
message

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
import { Button } from "@/components/ui/button"
import { useToast } from "@/hooks/use-toast"

export function ToastDemo() {
  const { toast } = useToast()

  return (
    <Button
      onClick={() => {
        toast({
          title: "Scheduled: Catch up",
          description: "Friday, February 10, 2023 at 5:57 PM",
        })
      }}
    >
      Show Toast
    </Button>
  )
}

API Reference

PropTypeDefaultDescription
variantdefault | destructivedefaultThe variant of the toast.
titleReact.ReactNode-The title of the toast.
descriptionReact.ReactNode-The description of the toast.
actionReact.ReactNode-An action component to display.