Skip to content
HomeCobalt

Toast

A short message about something that happened in the background.

Examples

Archiving has Undo; an export says when it is ready.
  • Q1 holdings report
  • Q2 holdings report
  • Q3 holdings report
Failure that staysA failure that stays until you dismiss it or retry.
In a dialogA toast raised from an open dialog shows above it.

Usage

Use it when

  • Something finished while you were elsewhere on the page: an export is ready, a background sync failed, an item was archived from a swipe and can be undone.
  • A result has no control of its own left on screen to report it, such as after a dialog closed or a row was removed.

Use something else when

  • The control that was pressed is still on screen and can report its own result. Use StateButton instead, which settles into "Saved" in place.
  • The result is an error you must act on in a form. Use Dialog's DialogError, or Field's FieldError on the field, instead, which stay until fixed.
  • The wait itself needs reporting, not its end. Use Spinner inside the control, or ListBody over the rows, instead.
  • The message is a confirmation that needs a decision. Use AlertDialog instead.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/toaster.json
import { Toaster, toast } from "@/components/cobalt/ui/toaster"