---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Toast

A short notice at a corner of the app that confirms an action and goes by itself, with an optional action such as Undo, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Toast`.

## Try it

Remove a note and press Undo in its toast (or Ctrl/Cmd+Z) within eight seconds: the note comes back where it was and takes the focus. Let the toast go and the removal is kept for good. Raise a plain toast and an error toast; several stack. Pick a look to see one card still: a picture and a link, a status glyph, the error toast with or without its words or a picture.

The notes live in the page only; “removed for good” only counts; the picture is a plain block of our own.

## When to use

- A short notice at a corner of the app that confirms an action and goes by itself, with an optional action such as Undo.
- Also called: notification or snackbar.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Toast on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/meadow-toast
```

```text
Add the Goop Toast to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { ToastIndicator, ToastAction, ToastButton } from '@/components/ui/goop/toast';

import type { ComponentProps } from 'react';
import { Button } from '@/components/ui/goop/button';
import { Toast, Toaster, toast } from '@/components/ui/goop/toast';

const OFFLINE = {
  title: 'You are offline',
  description: 'Your notes stay on this device and are sent when the connection is back.',
} satisfies ComponentProps<typeof Toast>;

function App() {
  return (
    <>
      <NoteActions save={() => Promise.resolve()} archive={() => {}} restore={() => {}} />
      <Toaster />
    </>
  );
}

function NoteActions({
  save,
  archive,
  restore,
}: {
  save: () => Promise<void>;
  archive: () => void;
  restore: () => void;
}) {
  return (
    <div className="flex gap-2">
      <Button
        onClick={() =>
          toast.promise(save, {
            loading: 'Saving the note',
            success: 'Note saved',
            error: { title: 'Couldn’t save the note', description: 'Check the connection and try again.' },
          })
        }
      >
        Save
      </Button>
      <Button
        variant="outline"
        onClick={() => toast.undo({ title: 'Note archived', onUndo: restore, onCommit: archive })}
      >
        Archive
      </Button>
      <Button variant="ghost" onClick={() => toast.warning(OFFLINE)}>
        Go offline
      </Button>
    </div>
  );
}
```

- Fits: account, app, settings (their recipes).
- Raise a notice with `toast`, never by drawing a Toast: every kind takes the title alone or the card's object, `toast.success('Saved')` or `toast.error({ title: 'Couldn’t save', description: 'The server did not answer.' })` (the object also takes `action`, `id`, `duration` and `closeButton`). Mount `<Toaster />` once for the whole app, in its root (App.tsx or the root layout, beside the screens), never once per page: `toast()` shows nothing without it.
- height, width, padding, gap, corner, background, shadow, text, motion: add no class for these.

## API reference

### Options

- `variant: default | info | success | warning | destructive | loading = default`

- Each option with its sentence: toast--options.md
- Types: ToastOptions = Omit<ComponentProps<typeof Toast>, 'id'> & { id?: string | number; duration?: number; toasterId?: string; closeButton?: boolean }; UndoToastOptions = Omit<ToastOptions, 'action'> & { onUndo: () => void; onCommit?: () => void; undoLabel?: string; shortcut?: string | false }

### Parts

- `ToastIndicator` — A status icon at the toast's start, a pack icon by its name, for a notice of your own (`mark`); decorative, as the title says what happened; its props: toast--indicator.md
- `ToastAction` — The link a notice ends with (`action={<ToastAction href>Words</ToastAction>}`); also takes href?: string
- `ToastButton` — A button a notice ends with (`action={<ToastButton onClick>Undo</ToastButton>}`); its props: toast--button.md
- `Toaster` — The toast region, mounted once near the root of the app, or once per named region (`id`); its props: toast--toaster.md
- `toast` — Shows a toast card in the app's `Toaster` and returns its id; `toast.error(…)` (the toast library's own name) or `toast.destructive(…)` (the theme's status word) shows the error card; `toast.success`, `toast.warning`, `toast.info` and `toast.loading` the other kinds

- Class recipes (cva): toastVariants (Toast)
- data-slot values (to select a part by): toast, toast-action, toast-badge, toast-badge-icon, toast-body, toast-close, toast-content, toast-description, toast-header, toast-icon, toast-indicator, toast-media, toast-spinner, toast-status, toast-title, toast-title-row

### ToastButton

A button a notice ends with (`action={<ToastButton onClick>Undo</ToastButton>}`).

```tsx
import { ToastButton } from '@/components/ui/goop/toast';
```

### Options

- Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

### ToastIndicator

A status icon at the toast's start, a pack icon by its name, for a notice of your own (`mark`); decorative, as the title says what happened.

```tsx
import { ToastIndicator } from '@/components/ui/goop/toast';
```

### Options

- icon: IconName — A pack icon name.

### Toast: every option

```tsx
import { Toast } from '@/components/ui/goop/toast';
```

### Options

- variant: default (default), info, success, warning, destructive, loading
- title: ReactNode — The notice's few words.
- description?: ReactNode — A line or two under the title.
- mark?: ReactNode — A glyph at the start, a `<ToastIndicator icon>`, in place of the kind's mark; not drawn when a `media` is given.
- media?: ReactNode — A 36 px picture at the start, the caller's image, in place of any glyph; a kind given it and no `mark` keeps its mark before the title.
- action?: ReactNode — What the notice ends with: a `ToastAction` link, or a `ToastButton` (on the title's line with no description).
- closeLabel?: string = 'Close' — The close cross's accessible name.
- kindLabel?: string — The words a screen reader hears before the title, saying the kind: "Error", "Warning", "Success", "Info" or "Loading" by default, none for the plain notice; an empty string says none.
- onDismiss?: () => void — Called when the close cross is pressed; given, the cross is drawn at the end of the title's line.

### Toaster

The toast region, mounted once near the root of the app, or once per named region (`id`).

```tsx
import { Toaster } from '@/components/ui/goop/toast';
```

### Options

- id?: string — The region's name: it shows only the notices raised with `toast({ toasterId })` of that name; none, only those raised with no name.

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Button](/themes/meadow/components/button): A button with words that runs an action, in several looks and sizes, on a page, in a row or in a sidebar.
- [Notification center](/themes/meadow/components/notification-center): A bell button with an unread count that opens a panel of notifications.
- [Account menu](/themes/meadow/components/account-menu): The signed-in person's menu.
- [Workspace switcher](/themes/meadow/components/workspace-switcher): The menu that shows the current workspace and switches to another or creates one.
