# Toast

A short-lived notification people can dismiss, with its action also available elsewhere.

- **Use it for**: A brief confirmation of something that happened, with an undo or retry.
- **Not for**: Errors people must act on. Try [Alert](https://unseenui.com/components/alert/).

## Installation

```bash
npm install @stackunseen/ui
```

## Parts

Notifications that appear in a corner and go away. One provider and one viewport serve a whole notification area.

```tsx
<ToastProvider>
  <Toast open={open} onOpenChange={setOpen} tone="success">
    <ToastTitle>Saved</ToastTitle>
    <ToastDescription>Your changes are on the server.</ToastDescription>
    <ToastAction altText="Open History to undo">Undo</ToastAction>
    <ToastClose />
  </Toast>
  <ToastViewport />
</ToastProvider>
```

1. **`ToastProvider`**: Wraps the area where toasts live.
2. **`Toast`**: One notification, announced politely. Props: `tone`.
3. **`ToastTitle`**: A short headline.
4. **`ToastDescription`**: One or two lines of detail.
5. **`ToastAction`**: An optional button. `altText` says how to do it once the toast is gone.
6. **`ToastClose`**: Dismisses the toast. Props: `label`.
7. **`ToastViewport`**: Where toasts appear. F8 moves focus there. Props: `position`, `container`, `portal`.

## Usage

```tsx
import { Toast } from '@stackunseen/ui';
import { ToastProvider, ToastTitle, ToastDescription, ToastAction, ToastClose, ToastViewport } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<ToastProvider><Toast open={open} onOpenChange={setOpen}><ToastTitle>Local sample updated</ToastTitle><ToastDescription>The notification can be dismissed.</ToastDescription><ToastClose /></Toast><ToastViewport /></ToastProvider>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `tone` | `FeedbackTone` |  |

## Keyboard

F8 moves focus into the notification area. Hover or focus pauses expiry; Escape dismisses a focused notification.

## Works with

[Alert](https://unseenui.com/components/alert/), [EmptyState](https://unseenui.com/components/empty-state/), [Progress](https://unseenui.com/components/progress/), [LoadingIndicator](https://unseenui.com/components/loading-indicator/), [Skeleton](https://unseenui.com/components/skeleton/), [StatusBadge](https://unseenui.com/components/status-badge/)

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