# Toast

> A brief confirmation that stacks, expands on hover, pauses when hidden and swipes away.

Category: Overlays · Atomic level: molecule · Built on Base UI Toast
Page: https://ui.dtheo.dev/docs/components/toast

## Install

```bash
npx dtheo@latest add toast
# or, with the shadcn CLI
npx shadcn@latest add https://ui.dtheo.dev/r/toast.json
```

Dependencies: @base-ui/react, clsx, tailwind-merge, lucide-react. Registry dependencies: utils.

## Exports

`Toaster`, `useToast`

## Use it for

- Confirming an action finished ("Run queued")
- Background events with an optional action (Undo)

## Reach for something else

- Errors that need a decision: use Alert or Alert dialog

## Accessibility

- Toasts are announced politely. Never put the only path to a feature in a toast.

## Examples

### toast

```tsx
import { Button } from '@/components/ui/button';
import { useToast } from '@/components/ui/toast';

export default function ToastExample() {
  const toast = useToast();

  const queueRun = () => {
    const id = toast.add({
      title: 'Retune run queued',
      description: 'R-0413 starts on Bench 3 at 15:10.',
      type: 'success',
      actionProps: {
        children: 'Undo',
        onClick: () => {
          toast.close(id);
          toast.add({ title: 'R-0413 removed from the queue' });
        },
      },
    });
  };

  const overheat = () =>
    toast.add({
      title: 'Winding at 78 °C',
      description: 'Bench 3 pauses the queue at 85 °C. R-0413 keeps running for now.',
      type: 'warning',
    });

  const uploadFailed = () => {
    const id = toast.add({
      title: 'Trace upload failed',
      description: 'R-0412 torque.csv: lost the connection to Bench 3. Retrying in 30 s.',
      type: 'error',
      actionProps: {
        children: 'Retry now',
        onClick: () => {
          toast.close(id);
          toast.add({ title: 'Trace uploaded', description: 'R-0412 torque.csv, 48 MB.', type: 'success' });
        },
      },
    });
  };

  return (
    <div className="flex flex-wrap items-center justify-center gap-2">
      <Button variant="primary" onClick={queueRun}>
        Queue retune run
      </Button>
      <Button onClick={overheat}>Simulate hot winding</Button>
      <Button onClick={uploadFailed}>Simulate failed upload</Button>
    </div>
  );
}
```

## Used in

- Run review (page): https://ui.dtheo.dev/examples/run-review
- Motor map (page): https://ui.dtheo.dev/examples/motor-map
- Loop tuning (page): https://ui.dtheo.dev/examples/tuning
- Lab assistant (page): https://ui.dtheo.dev/examples/assistant
- Data table pattern (template): https://ui.dtheo.dev/docs/patterns/data-table
- Forms pattern (template): https://ui.dtheo.dev/docs/patterns/forms
