Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Toast for React and Tailwind

Provides feedback on an action.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/toast.json

Usage

import { Toaster } from "@/components/ui/toast";
const toaster = useToast();

// add the toaster to the layout
<Toaster toaster={toaster} />

// show a toast
toaster.create({
  title: "Show Info Toast",
  description: "This is an info toast",
  type: "info",
});

Deduplication

Toasts with the same id are deduplicated. If no id is passed, a new toast is created.

Placement

By default, the toaster is placed at the bottom right corner of the screen.

Update the placement option in createToaster() to customize the toaster position.

components/ui/toast.tsx
const baseToaster = createToaster({
  placement: "bottom-end",
  overlap: true,
  max: 4,
});

Max toasts

Any extra toasts will be queued and rendered when a toast has been dismissed.

By default, the toaster displays up to 3 toasts. Update the max option in createToaster() to change the maximum number of visible toasts.

components/ui/toast.tsx
const baseToaster = createToaster({
  placement: "bottom-end",
  overlap: true,
  max: 4,
});

Examples

Variants

Use success, error, warning, and info for the matching icon and accent color.

You can also pass type on toast.create.

Promise

Action

Duration

Control how long a toast stays visible with the duration option.

Use Infinity to keep the toast visible until the user dismisses it.

Not Closable

Use closable prop to control whether the close button is shown.

API Reference

Toaster

Toast container. Place once in your app layout.

PropTypeDefault
toasterReturnType<typeof createToaster>-
classNamestring-

toast

Toast instance. Used to create and manage toasts.

PropTypeDefault
titlestring-
descriptionstring-
type"success" | "error" | "warning" | "info" | "loading""info"
durationnumber3000
closablebooleantrue

For a complete list of props, see the Ark UI documentation.