# Toast

> A single transient notification.

- Category: [Actions & feedback](https://tarve.dev/docs.md#actions)
- Import: `import { Toast } from "@tarve/core";`
- Props type: `ToastProps`
- Source: [packages/core/src/extra-controls.ts:894](https://github.com/omarcosr/tarve/blob/main/packages/core/src/extra-controls.ts#L894)

## Usage

```tsx title="Toast.tsx"
import { Toast } from "@tarve/core";

<Toast
  id="saved"
  variant="success"
  title="Changes saved"
  description="Everything is up to date."
  action={{ label: "Undo", onClick: () => console.log("undo") }}
  onDismiss={(id) => console.log("dismissed", id)}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` (required) | `string` | — |  |
| `title` (required) | `string` | — |  |
| `action` | `ToastAction` | — |  |
| `description` | `string` | — |  |
| `onDismiss` | `(id: string) => void` | — |  |
| `variant` | `ToastVariant` | `"default"` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="ToastAction"
interface ToastAction {
  label: string;
  onClick: () => void;
}
```

```ts title="ToastVariant"
type ToastVariant = "default" | "success" | "destructive";
```

Previous: [Alert](https://tarve.dev/docs/components/Alert.md) · Next: [Toaster](https://tarve.dev/docs/components/Toaster.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Toast · Index for agents: https://tarve.dev/llms.txt
