# Toaster

> A complete toast system: call toast(), toast.success() or toast.promise() from anywhere and a Toaster renders them as a collapsed deck that fans out on hover. Six positions, swipe or Escape to dismiss, timers that hold on hover and in hidden tabs, morphing icons when a promise settles, and Alt+T to jump to the stack.

- Slug: `toaster`
- Category: [Toasts](https://www.assembli.design/category/toasts.md)
- Type: component
- Tags: toast, toaster, sonner, stack, promise, swipe, snackbar
- npm dependencies: motion, lucide-react
- shadcn/ui dependencies: none
- Live preview: https://www.assembli.design/preview/toaster
- Page: https://www.assembli.design/components/toaster

![Toaster preview](https://www.assembli.design/thumbnails/toaster-light.png)

## Props

Other props pass through to the root element.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `position` | `ToastPosition` | `"bottom-right"` |  |
| `expand` | `boolean` | `false` | Keep the stack fanned out instead of collapsing it into a deck. |
| `visibleToasts` | `number` | `3` | How many toasts show at once; older ones wait behind the deck. |
| `duration` | `number` | `4000` | Default lifetime in milliseconds. |
| `gap` | `number` | `12` | Space between toasts when the stack is fanned out. |
| `offset` | `number` | `24` | Distance from the edges of the viewport (or the positioned parent). |
| `strategy` | `"fixed" \| "absolute"` | `"fixed"` | `absolute` pins the stack inside the nearest positioned parent instead of the viewport. |
| `closeButton` | `boolean` | `true` |  |
| `hotkey` | `{ altKey?: boolean; metaKey?: boolean; ctrlKey?: boolean; shiftKey?: boolean; c…` | `{ altKey: true, code: "KeyT" }` | Keyboard shortcut that focuses the stack. |

## Install

One-time setup (needs a subscription):

1. Add the registry to the project's `components.json`: `{"@assembli":{"url":"https://www.assembli.design/r/{name}.json","headers":{"Authorization":"Bearer ${ASSEMBLI_API_KEY}"}}}` (merge into `"registries"`).
2. Put an API key from https://www.assembli.design/account in `.env.local` as `ASSEMBLI_API_KEY=asm_…`.

Then install with the shadcn CLI (writes `components/toaster/toaster.tsx` and installs dependencies):

```bash
npx shadcn@latest add @assembli/toaster
```

Registry item JSON: https://www.assembli.design/r/toaster.json (send `Authorization: Bearer <api key>`)

## Code

> Component source needs an Assembli subscription ($12/month or $96/year) and an API key sent as `Authorization: Bearer <key>`. To get one without copying anything, POST https://www.assembli.design/api/agent/login (or call the MCP tool connect_account), show the user the link it returns, and poll https://www.assembli.design/api/agent/token for the key. Or subscribe at https://www.assembli.design/pricing and create a key at https://www.assembli.design/account.
