Skip to main content

Import

Setup

Add the ToastContainer component to your app root:

Usage

Basic toast

Toast types

Promise-based toast

With custom duration

With description

With action button

Dismissing toasts

With custom styling

With callbacks

JSX content

Loading states

Simple loading

Loading with promise

API reference

toast()

The main function to display toast notifications.
string | React.ReactNode
required
The content to display in the toast. Can be a string or JSX element.
ToastOptions
Configuration options for the toast.

Toast options

number
default:"4000"
Time in milliseconds before the toast auto-dismisses. Set to Infinity to prevent auto-dismiss.
string
Additional description text displayed below the main message.
{ label: string; onClick: () => void }
Action button configuration with label and click handler.
string | number
Custom identifier for the toast. Useful for updating or dismissing specific toasts.
string
Additional CSS class names to apply to the toast.
CSSProperties
Inline styles to apply to the toast.
() => void
Callback function called when the toast is dismissed manually.
() => void
Callback function called when the toast auto-closes after the duration.

toast.success()

Displays a success toast.

toast.error()

Displays an error toast.

toast.warning()

Displays a warning toast.

toast.info()

Displays an info toast.

toast.loading()

Displays a loading toast.

toast.promise()

Displays a toast that updates based on promise state.

toast.dismiss()

Dismisses one or all toasts.
string | number
The ID of the toast to dismiss. If omitted, all toasts will be dismissed.

ToastContainer

Container component that renders the toast notifications.
'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
Position where toasts appear on the screen.
'light' | 'dark' | 'system'
Color theme for toasts. Defaults to system preference.
boolean
Whether to use rich colors for different toast types.
boolean
Whether toasts expand to show full content on hover.
number
default:"3"
Maximum number of toasts visible at once.