# Toast

A short message that appears at the top right to confirm an action, then goes away.

This is the HTML to build it with `dex.css`, for work outside the Dex codebase. Read https://brand.meetdex.ai/design.md first: it says how to set up a page and how to use the stylesheet. The page at https://brand.meetdex.ai/components/toast shows the Dex app's own React component, which only works inside the Dex codebase.

## HTML

A `dex-toast`: an icon, a title, one line and at most one action. Place it at the top right with layout CSS of your own:

```html
<div style="position: fixed; top: 1rem; right: 1rem; z-index: 60" aria-live="polite">
  <div class="dex-toast" role="status">
    <svg aria-hidden="true" style="width: 1rem; height: 1rem; flex-shrink: 0; color: var(--dex-success)"><!-- Lucide circle-check --></svg>
    <div style="flex: 1; min-width: 0">
      <div style="font-weight: 500">Application sent</div>
      <div class="dex-muted">Synthesia will see it today.</div>
    </div>
    <button class="dex-button dex-button--outline dex-button--sm">Undo</button>
  </div>
</div>
```

- **Types**: the icon says which. Success is a Lucide `circle-check` in `--dex-success`, an error a `circle-x` in `--dex-destructive`, a warning a `triangle-alert` in `--dex-warning-strong`, news an `info` in `--dex-info`. The toast itself stays the same card.
- **Without a description**: the title alone ("Application sent").
- **Going away**: remove it after about four seconds (`setTimeout`), or when its action is pressed.

## Rules

- A toast reports something that has already happened: "Role saved", "Application sent". Show it once the request has worked or failed, not when the button is pressed.
- Use the type that fits: success when the action worked, error when it failed, info for news that is neither.
- Show one toast per event. When the same event can fire twice, replace the toast already showing rather than stacking another.
- An error says what to do next: "We couldn't save your CV" with "Check your connection and try again."
