---
title: "Toast"
description: "A short message in a corner of the screen after people do something, such as a saved file. It closes on its own, stacks with others, and swipes away."
url: https://gelatinui.com/components/toast
markdown_url: https://gelatinui.com/components/toast.md
access: free
install: "npx shadcn@latest add @gelatin-ui/toast"
registry_item: https://gelatinui.com/r/toast.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Toast

> A short message in a corner of the screen after people do something, such as a saved file. It closes on its own, stacks with others, and swipes away.

Page: https://gelatinui.com/components/toast

## When to use it

Best for: A short message about an action people just did, that times out on its own.

- Use it for a short message about an action that people just did.
- Call `toast.add()` from anywhere, also outside React. Render one `Toaster` in a `ToastProvider` near the app root.
- Give a toast with an action a longer `timeout`, so a keyboard user can reach it.

## When not to use it

- For a message that must stay on the page, use an [Alert](https://gelatinui.com/components/alert.md).
- For a choice that people must make before they go on, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).

## Notes for agents

- Render one `Toaster` in a `ToastProvider` near the app root, then call `toast.add()` from anywhere, also outside React.
- Give a toast with an action a longer `timeout`, so a keyboard user can reach it.

## Anatomy

```text
Toast
├─ ToastPortal (0..n)
├─ ToastViewport (0..n)
├─ ToastContent (0..n)
├─ ToastIcon (0..n)
├─ ToastHeader (0..n)
├─ ToastTitle (0..n)
├─ ToastDescription (0..n)
├─ ToastAction (0..n)
├─ ToastClose (0..n)
├─ ToastPositioner (0..n)
├─ ToastArrow (0..n)
├─ Toaster (0..n)
└─ AnchoredToaster (0..n)
```

## API reference

### ToastPortal

Also takes every prop of Base UI `Toast.Portal`: https://base-ui.com/react/components/toast

### ToastViewport

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `position` | `"bottom-center" \| "bottom-end" \| "bottom-start" \| "top-center" \| "top-end" \| "top-start"` | "bottom-end" |  |
| `className` | `string` |  |  |
| `variant` | `"default" \| "inverse"` | "default" | The look of every toast in this viewport: `default` (the popover surface) or `inverse` (the foreground surface). One look per stack: mixed looks in a collapsed stack show a dark card peeking out under a light one. |

### Toast

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `swipeDirection` | `union` |  | Directions that dismiss it. By default: toward the edge and the side of the viewport. |

Also takes every prop of Base UI `Toast.Root`: https://base-ui.com/react/components/toast

### ToastContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### ToastIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | `string` |  | The toast `type`. `success`, `destructive`, `warning`, and `info` show an icon, `loading` a spinner. The `error` type of Base UI `toast.promise` shows as `destructive`. |

### ToastHeader

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ToastTitle

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### ToastDescription

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### ToastAction

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### ToastClose

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### ToastPositioner

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Toast.Positioner`: https://base-ui.com/react/components/toast

### ToastArrow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### Toaster

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `variant` | `"default" \| "inverse"` |  | The look of every toast in this viewport: `default` (the popover surface) or `inverse` (the foreground surface). One look per stack: mixed looks in a collapsed stack show a dark card peeking out under a light one. |
| `position` | `"bottom-center" \| "bottom-end" \| "bottom-start" \| "top-center" \| "top-end" \| "top-start"` |  |  |
| `container` | `ToastPortalProps["container"]` |  | Where the viewport renders (Base UI `Toast.Portal`). By default, the end of `<body>`. |
| `closeLabel` | `string` |  | The accessible name of each close button ("Close" by default). Translate it with the page. |

### AnchoredToaster

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `container` | `ToastPortalProps["container"]` |  | Where the toasts render (Base UI `Toast.Portal`). By default, the end of `<body>`. |
| `arrow` | `boolean` | true | Show the arrow that points at the anchor. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ToastPortal | `toast-portal` |  |  |  |
| ToastViewport | `toast-viewport` |  | `--action-bar-offset`, `--spacing` | `motion-timing` |
| Toast | `toast` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastContent | `toast-content` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastIcon | `toast-icon` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastHeader | `toast-header` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastTitle | `toast-title` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastDescription | `toast-description` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastAction | `toast-action` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastClose | `toast-close` | `data-behind`, `data-ending-style`, `data-expanded`, `data-limited`, `data-position`, `data-starting-style`, `data-swipe-direction`, `data-swiping` | `--toast-clamped-height`, `--toast-frontmost-height`, `--toast-gap`, `--toast-height`, `--toast-index`, `--toast-offset-y`, `--toast-peek`, `--toast-scale`, `--toast-sign`, `--toast-swipe-movement-x`, `--toast-swipe-movement-y`, `--toast-y` | `motion-timing`, `status-colors` |
| ToastPositioner | `toast-positioner` |  | `--available-width` |  |
| ToastArrow | `toast-arrow` |  |  |  |
| Toaster | `toaster` |  |  |  |
| AnchoredToaster | `toast-viewport` |  |  |  |

## Usage

Render one `Toaster` in a `ToastProvider` near the app root, then call `toast.add()` from anywhere. Give a toast with an action a longer `timeout`, so a keyboard user can reach it.

```tsx title="delete-file.tsx"
import { Button } from "@/components/ui/button";
import { ToastProvider, Toaster, toast } from "@/components/ui/toast";

function showDeleted(onUndo: () => void) {
  toast.add({
    title: "File deleted",
    description: "report.pdf",
    timeout: 10_000,
    actionProps: { children: "Undo", onClick: onUndo },
  });
}

export function DeleteFile({ onUndo }: { onUndo: () => void }) {
  return (
    <ToastProvider>
      <Button onClick={() => showDeleted(onUndo)}>Delete file</Button>
      <Toaster position="bottom-end" />
    </ToastProvider>
  );
}
```

## Compose

Build it with:

- [Sidebar](https://gelatinui.com/components/sidebar.md): Moves between the settings sections.
- [Frame](https://gelatinui.com/components/frame.md): Groups the fields of one section, with Save in its footer.
- [Field](https://gelatinui.com/components/field.md): Names each control and shows its help or error text.
- [Switch](https://gelatinui.com/components/switch.md): Turns one setting on or off at once.
- [Select](https://gelatinui.com/components/select.md): Picks one value from a short list.
- [Button](https://gelatinui.com/components/button.md): Saves the section or opens a dialog.
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md): Asks for the confirm and blocks the page.

Rules:

- Group with a Frame (`group-in-frames`): Put related panels in one `Frame` with its header and footer outside the panels, and keep a plain `Card` for one block of content.
- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Labels real apps use (`real-labels`): Write the button and menu labels that real apps use ("Create API key", "Invite members"), with no "…" at the end.
- No layout jump (`no-layout-jump`): When a state change adds, removes, or resizes content, reserve its space or animate its size, so nothing below it jumps.

Patterns: `gelatin://patterns/settings-page`, `gelatin://patterns/confirm-action`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/toast
```

It adds 19 registry items: 16 files, 2887 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Spinner](https://gelatinui.com/components/spinner.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Alert](https://gelatinui.com/components/alert.md): Pick Alert for a message that must stay in the page until its cause goes away.
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md): Pick Alert Dialog when people must answer yes or no before they go on.
- [Button](https://gelatinui.com/components/button.md)

## Keyboard

| Keys | Action |
| --- | --- |
| F6 | Moves focus into the toasts and pauses every timer. |
| Shift Tab | Moves focus back out of the toasts. |
| Esc | Closes the focused toast. |

## Accessibility

The viewport is a Base UI `Toast.Viewport`: a landmark with `role="region"` and `aria-live="polite"`. Base UI names it "Notifications" in English. Pass a translated `aria-label`.

Each toast is a `role="dialog"`, named by its title. A toast with `priority: "high"` is an `alertdialog`, and a screen reader reads it at once. A `low` toast (the default) is read after the current speech.

The status icon is `aria-hidden`, because the title says the same thing in words. The close button is named "Close". Set `closeLabel` on `Toaster` to translate it.

F6 moves focus into the toasts and pauses every timer. Hover also pauses them. Swipe is never the only way out: the close button and the timeout also remove a toast. The close button and the action are 24px, with a 44px target on touch (`hit-area`).

## Motion

| Part | Motion |
| --- | --- |
| Enter and stack | toast · 300ms · ease-panel (0.2, 0.4, 0.2, 1) |
| Close | toast-exit · 150ms · ease-out (0, 0, 0.2, 1) |
| Anchored toast | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) |
