# Toast

Transient status notification delivered via an imperative `toast()` store and `<Toaster />` viewport, built on Radix Toast.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| Toaster.position | "bottom-right" \| "top-right" | "bottom-right" | Viewport corner on >=640px screens; collapses to full-width bottom-center or top-center on mobile. |

## Sizes and tokens

| Tier / Role | Token | Value |
| --- | --- | --- |
| Viewport width & margin | sm:w-[26rem] / p-4 / --z-toast | 384px toast width · 16px viewport margin · full-width on <640px · z-index 50 |
| Queue capacity | MAX_VISIBLE_TOASTS | 3 visible max · FIFO queue for overflow · newest nearest edge |
| Neutral & feedback surfaces | popupSurface / alertVariants / --shadow-lg | Neutral uses popover surface; feedback variants reuse Alert subtle tints and icons |
| Motion | --duration-262 / --duration-162 | 16px edge slide + fade (262ms enter, 162ms exit); opacity-only under reduced motion |

## Code

```tsx
import { Button, Toaster, toast } from "@freshgemui/monoplinth";

export function Example() {
  return (
    <>
      <Button
        onClick={() =>
          toast({
            title: "Tokens exported",
            description: "CSS variables written to tokens/theme.css.",
            variant: "success",
            action: {
              label: "Undo",
              altText: "Undo token export",
              onClick: () => {},
            },
          })
        }
      >
        Export tokens
      </Button>
      <Toaster position="bottom-right" />
    </>
  );
}
```

## Do and don't

- **Do: Use Toast for brief, non-blocking feedback** — Confirm background saves, exports, or undoable actions without interrupting the user's current focus.
- **Don't: Auto-dismiss toasts with actions** — Always keep action toasts open until the user acts or dismisses them (enforced automatically when action is provided).

## Accessibility

- `destructive` toasts use Radix `type="foreground"` (`assertive` live region), while all other variants use `type="background"` (`polite`).
- Press `F8` to jump keyboard focus to the `<Toaster />` viewport; timers pause automatically on hover and focus (WCAG 2.2.1).
- Each toast renders at `z-toast` (50) with `pointer-events-auto`, keeping close and action buttons clickable even when a `Dialog` or `Sheet` is open.

## Rationale

Capping visible toasts at three with a FIFO queue prevents viewport clutter, while reusing `Alert` variant tints and icons keeps semantic feedback consistent across inline and floating surfaces.
