Toast

Toast notifications to display feedback to users.

Overview

Toast notifications are managed through the useToastActions hook, which is provided by the ToastsProvider wrapper. Toasts are built on Base UI's toast manager: they close after 5 seconds, pause while hovered or focused, and can be swiped right to dismiss. Loading toasts stay open until they are updated or removed.

Basic usage

API

The toast.create() method accepts the following options:

  • title (optional): Toast title
  • description (optional): Toast description
  • type (optional): 'default' | 'loading' | 'success' | 'warning' | 'error'
  • action (optional): A <ToastAction> component for user interaction

toast.create() returns the toast id. Pass it to toast.update(id, options) to change the toast, or to toast.remove(id) to close it.

Examples

Usage toast

With title

With action

ToastAction does not close the toast on click. Call toast.remove(id) in its handler when the action should dismiss it.

Toast types

Success toast

Warning toast

Error toast

Updating from the current toast

update accepts a partial object or a function receiving the current toast. Omitted fields keep their current values; pass undefined explicitly to clear a field.