<!-- generated by scripts/gen-docs.mjs from docs/system/alert-dialog.md. Edit the source and rerun. -->
# AlertDialog

## Description
Asks you to confirm before continuing, usually before a delete.

`import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogError, AlertDialogCancel, AlertDialogAction } from "@/components/cobalt/ui/alert-dialog"`, source `registry/cobalt/ui/alert-dialog.tsx`, status `ready-with-gaps`.
Foundation: `shadcn alert-dialog (base-luma, base)`. Traps checked: `trap/overlay-title`, `trap/overlay-focus-return`, `trap/overlay-conditional-render`, `trap/exit-eats-input`, `trap/escape-nested`, `trap/overlay-destructive`, `trap/overlay-pending-dismiss`, `trap/overlay-no-max-height`, `trap/open-trigger-unfocused`, `trap/scroll-chain`, `trap/viewport-height`, `trap/safe-area` (n/a: the popup floats inside the page gutters), `trap/touch-autofocus` (n/a: the popup holds no field; focus lands on Cancel), `trap/motion-origin`, `trap/motion-exit-slower`, `trap/reduced-motion-ignored`, `trap/motion-frequent` (n/a: tier mid in `.design-system/review/surfaces.tsv`, opened once per decision).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Base UI `AlertDialog`: a portalled `role="alertdialog"` popup named by its `Title` and described by its `Description`, a trigger with `aria-haspopup="dialog"`, focus moved to the first tabbable control on open and back to the trigger on close, Escape to close and no outside-press dismissal, `data-starting-style` and `data-ending-style` for the transition | The `status` prop on `AlertDialogContent`: while `"pending"` the root cancels every close that is not imperative, the popup carries `aria-busy` and `AlertDialogCancel` carries `aria-disabled` while keeping focus (`registry/cobalt/ui/alert-dialog.tsx:38`, `registry/cobalt/ui/alert-dialog.tsx:185`); `size`, `default` or `sm`, which centres the text and puts the two actions side by side; the shared `Overlay` as the backdrop (`registry/cobalt/ui/alert-dialog.tsx:75`); the second click of the double-click that opened it dropped, so it selects no word of the question and presses no action under the pointer, while a press that begins inside the open dialog selects as usual (`guardOpeningClick`, `registry/cobalt/ui/alert-dialog.tsx:78`); the portal container and the inert page from `registry/cobalt/lib/portal.tsx`; a width of the viewport minus two gutters up to 320px, 448px for `default` from 640px, so it never touches a phone's edges, and a max height of the viewport minus two gutters (`registry/cobalt/ui/alert-dialog.tsx:86`); a column in which a long `AlertDialogDescription` scrolls on its own between the title and the actions, which stay, a tab stop only while it overflows; `overflow-wrap: anywhere` on the popup, so a file name or an address breaks rather than run past the edge; `rounded-4xl` on `bg-popover` with `shadow-sheet`, one soft shadow and no edge line; `text-sm` on the popup, as on Dialog's, so anything unstyled in the body or footer is 14px; the title at `text-base font-semibold`, the same as the dialog and the sheet; `AlertDialogError`, a `role="alert"` line for the footer that takes its own line above the actions, and a footer that wraps actions too long to sit side by side (`registry/cobalt/ui/alert-dialog.tsx:113`); `AlertDialogCancel` rendered as a ghost Button and `AlertDialogAction` as a Button with the caller's variant; no corner close button and no icon disc above the title |

## Examples
An alert dialog that asks before deleting, holds while the delete is pending, and keeps the error when it fails.

Real uses, 0 call sites (`rg -n "<AlertDialog\b" app docs/system/examples --glob '!docs/system/examples/alert-dialog/*'`): the showcase chrome renders no AlertDialog of its own yet, and the examples folder does not count.

Uses inside the registry, which other components build on (planned as product uses once the first screen lands on the system):
- The Button spec lists the action and the cancel as its registry uses, `registry/cobalt/ui/alert-dialog.tsx:172` and `registry/cobalt/ui/alert-dialog.tsx:187`.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/alert-dialog/default.tsx` | default | Asks before deleting, holds while pending, then confirms |
| Not applicable: the default size is default.tsx | size=default | Text aligned to the start from 640px up, the actions in a row at the end |
| `docs/system/examples/alert-dialog/size-sm.tsx` | size=sm | Centred text and two actions side by side |
| Not applicable: the open state is reached by pressing the trigger on any example | state:open | The popup over the scrim with focus on Cancel |
| Not applicable: closing is reached with Escape or Cancel on any example; the scrim does nothing | state:closing | The popup and the scrim fade out in 70 percent of the arrive time |
| Not applicable: pending is reached by pressing "Delete" in default.tsx | state:pending | Escape and Cancel do nothing; the action shows its spinner in place |
| Not applicable: failure is reached two seconds after "Delete" in default.tsx | state:failure | The error announced in the footer, the dialog still open, Cancel enabled again |
| `docs/system/examples/alert-dialog/default.tsx` | composition:StateButton | The delete is a StateButton that keeps its place and its name while pending |

Example: Asks before deleting, holds while pending, then confirms (`docs/system/examples/alert-dialog/default.tsx`)

```tsx
import { useState } from "react";
import { toast } from "sonner";

import {
  AlertDialog,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogError,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/cobalt/ui/alert-dialog";
import { Button } from "@/components/cobalt/ui/button";
import { StateButton } from "@/components/cobalt/ui/state-button";
import { useAction } from "@/lib/cobalt/use-action";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

export default function Example() {
  const [open, setOpen] = useState(false);
  const remove = useAction(async () => {
    await request();
    setOpen(false);
    // The dialog that held the result has closed, so a toast says it happened.
    toast("Credit funds watchlist deleted", { description: "Its 14 funds and 3 alerts are gone." });
  });
  return (
    <>
      <AlertDialog
        open={open}
        onOpenChange={(next) => {
          setOpen(next);
          if (!next) remove.reset();
        }}
      >
        <AlertDialogTrigger render={<Button variant="destructive" />}>Delete watchlist</AlertDialogTrigger>
        <AlertDialogContent status={remove.status}>
          <AlertDialogHeader>
            <AlertDialogTitle>Delete Credit funds?</AlertDialogTitle>
            <AlertDialogDescription>
              Its 14 funds and the 3 alerts set on them are deleted too. This cannot be undone.
            </AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter>
            {remove.error !== null && (
              <AlertDialogError>
                The watchlist was not deleted. Check your connection and try again.
              </AlertDialogError>
            )}
            <AlertDialogCancel>Keep watchlist</AlertDialogCancel>
            <StateButton
              variant="destructive"
              status={remove.status}
              pendingLabel="Deleting"
              failureLabel="Not deleted"
              onClick={() => void remove.run()}
            >
              Delete watchlist
            </StateButton>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
    </>
  );
}
```

Example: The delete is a StateButton that keeps its place and its name while pending (`docs/system/examples/alert-dialog/default.tsx`)

```tsx
import { useState } from "react";
import { toast } from "sonner";

import {
  AlertDialog,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogError,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/cobalt/ui/alert-dialog";
import { Button } from "@/components/cobalt/ui/button";
import { StateButton } from "@/components/cobalt/ui/state-button";
import { useAction } from "@/lib/cobalt/use-action";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

export default function Example() {
  const [open, setOpen] = useState(false);
  const remove = useAction(async () => {
    await request();
    setOpen(false);
    // The dialog that held the result has closed, so a toast says it happened.
    toast("Credit funds watchlist deleted", { description: "Its 14 funds and 3 alerts are gone." });
  });
  return (
    <>
      <AlertDialog
        open={open}
        onOpenChange={(next) => {
          setOpen(next);
          if (!next) remove.reset();
        }}
      >
        <AlertDialogTrigger render={<Button variant="destructive" />}>Delete watchlist</AlertDialogTrigger>
        <AlertDialogContent status={remove.status}>
          <AlertDialogHeader>
            <AlertDialogTitle>Delete Credit funds?</AlertDialogTitle>
            <AlertDialogDescription>
              Its 14 funds and the 3 alerts set on them are deleted too. This cannot be undone.
            </AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter>
            {remove.error !== null && (
              <AlertDialogError>
                The watchlist was not deleted. Check your connection and try again.
              </AlertDialogError>
            )}
            <AlertDialogCancel>Keep watchlist</AlertDialogCancel>
            <StateButton
              variant="destructive"
              status={remove.status}
              pendingLabel="Deleting"
              failureLabel="Not deleted"
              onClick={() => void remove.run()}
            >
              Delete watchlist
            </StateButton>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
    </>
  );
}
```

## Variants

### size
- `default`: the decision with a sentence or two of consequence; text starts at the leading edge from 640px up and the actions sit in a row at the end. Used at 0 call sites outside the examples.
- `sm`: a yes or no with one line of consequence; text centred at every width, the two actions side by side in a 2 column grid. Used at 0 call sites outside the examples.

Example: Centred text and two actions side by side (`docs/system/examples/alert-dialog/size-sm.tsx`)

```tsx
import { useState } from "react";

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/cobalt/ui/alert-dialog";
import { Button } from "@/components/cobalt/ui/button";

export default function Example() {
  const [open, setOpen] = useState(false);
  return (
    <AlertDialog open={open} onOpenChange={setOpen}>
      {/* An editor's Close, pressed with changes not yet saved. */}
      <AlertDialogTrigger render={<Button variant="secondary" />}>Close</AlertDialogTrigger>
      <AlertDialogContent size="sm">
        <AlertDialogHeader>
          <AlertDialogTitle>Leave without saving?</AlertDialogTitle>
          <AlertDialogDescription>Your changes to the list are lost.</AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel>Keep editing</AlertDialogCancel>
          <AlertDialogAction
            variant="destructive"
            onClick={() => {
              setOpen(false);
            }}
          >
            Leave
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| closed | render, or `open={false}` | press the trigger | nothing is in the tree but the trigger | test |
| open | the trigger, or `open` | cancel, confirm, Escape | the popup centred over the scrim, focus on Cancel, the page behind inert | a11y scan |
| closing | Escape, Cancel, the action's own close | press the trigger again once it is gone | `data-ending-style` on the popup and the scrim, which take no pointer input while they fade | by hand |
| pending | `status="pending"` on `AlertDialogContent` | wait; a second press on the action returns early in `StateButton` | `aria-busy` on the popup, `aria-disabled` on Cancel, the spinner inside the action | a11y scan |
| failure | the host renders `AlertDialogError` in the footer | read the error, try again, cancel | the `role="alert"` line on its own line above the actions, the dialog still open | a11y scan |
| scrolling | content taller than the viewport minus two gutters | scroll the description; the title and the actions stay | the description clipped with `overflow-y: auto` and a tab stop while it overflows; measured on `/stress/alert-dialog?data=worst` at 320 and 200% text | screenshot |

### State precedence
- Pending and closing: pending wins. Escape and Cancel are cancelled by the root until the status leaves pending; only the host's own `open={false}` closes it.
- Pending and failure: Not applicable: `status` is one value at a time.
- Failure and open: both show. The dialog stays open with the error until you retry or cancel, and Cancel is enabled again.
- Open and scrolling: both show. The description scrolls inside the max height; the title, the actions, the scrim and the page stay.
- Closing and open: closing wins. The fading layer takes no input, and a press on the trigger is a new open (`trap/exit-eats-input`).
- Open and the second click of the double-click that opened it: open wins, and the click is dropped. Measured on both examples at 1440 and 390, light and dark: before, the click selected "Delete" in the title at 1440; after, nothing is selected and no action is pressed, while a double-click on a word of the open dialog still selects it (`.design-system/evidence/dialog/double-click.json`).

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| closed to open | announce | `dialog-motion`, `--t-arrive` on `--curve`, a fade in place, centred (`trap/motion-origin`: nothing scales) | opacity 0 to 1 | the fade stays, measured `transition-property: opacity` only under reduce in `.design-system/evidence/alert-dialog/open-390x320.json` |
| open to closed | announce | `dialog-motion`, 70 percent of `--t-arrive` on `--curve` (`trap/motion-exit-slower`) | opacity 1 to 0 | the fade only |
| scrim in and out | announce | `overlay-motion`, `--t-arrive` and 70 percent of it on `--curve` | opacity | the same fade |

## Props

<!-- Props generated from registry/cobalt/ui/alert-dialog.tsx with TypeScript by scripts/props-table.mjs -->
### AlertDialog

No props of its own.

Also accepts from Base UI: `actionsRef`, `defaultOpen`, `defaultTriggerId`, `handle`, `onOpenChange`, `onOpenChangeComplete`, `open`, `triggerId`.

### AlertDialogAction

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `size?` | `"default" \| "sm" \| "lg" \| "icon" \| "icon-sm" \| "icon-xs" \| "icon-lg"` |  | `default` the decision with a sentence or two of consequence; `sm` a yes or no with one line of consequence. |
| `variant?` | `"default" \| "secondary" \| "ghost" \| "destructive"` |  |  |

Also accepts every native `<button>` attribute; from Base UI: `focusableWhenDisabled`, `nativeButton`, `render`.

### AlertDialogCancel

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `size?` | `"default" \| "sm" \| "lg" \| "icon" \| "icon-sm" \| "icon-xs" \| "icon-lg"` | `"default"` | `default` the decision with a sentence or two of consequence; `sm` a yes or no with one line of consequence. |
| `variant?` | `"default" \| "secondary" \| "ghost" \| "destructive"` | `"ghost"` |  |

Also accepts every native `<button>` attribute; from Base UI: `nativeButton`, `render`.

### AlertDialogContent

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `size?` | `"default" \| "sm"` | `"default"` | `default` the decision with a sentence or two of consequence; `sm` a yes or no with one line of consequence. |
| `status?` | `WriteStatus` | `"idle"` | While pending, nothing dismisses the dialog: the action decides when it closes. |

Also accepts every native `<div>` attribute; from Base UI: `finalFocus`, `initialFocus`, `render`.

### AlertDialogDescription

No props of its own.

Also accepts every native `<p>` attribute; from Base UI: `render`.

### AlertDialogError

No props of its own.

Also accepts every native `<p>` attribute.

### AlertDialogFooter

No props of its own.

Also accepts every native `<div>` attribute.

### AlertDialogHeader

No props of its own.

Also accepts every native `<div>` attribute.

### AlertDialogTitle

No props of its own.

Also accepts every native `<h2>` attribute; from Base UI: `render`.

### AlertDialogTrigger

No props of its own.

Also accepts every native `<button>` attribute; from Base UI: `handle`, `id`, `nativeButton`, `payload`, `render`.

`AlertDialogContent` adds `size` and `status` (`Status` from `registry/cobalt/lib/status.ts`: while `"pending"` nothing dismisses the dialog). `AlertDialogCancel` takes Button's `variant` (default `ghost`) and `size`; `AlertDialogAction` takes every Button prop, so the destructive wash is `variant="destructive"`. Everything on Base UI's root passes through `AlertDialog`: `open`, `defaultOpen`, `onOpenChange` with the reason, `onOpenChangeComplete`. There is no `showCloseButton`: the two footer actions are the only ways out. `className` on every part is merged last and is for placement.

## Usage

### When to use
- An action removes, overwrites or sends something that cannot be taken back, and you must confirm first.
- Leaving a form would lose what was typed.

### When not to use
- The task has a form or more than one decision. Use Dialog instead.
- The action can be undone afterwards. Use Toaster with an undo action instead, and skip the question.
- The choice is between two equal paths, not a confirm. Use Dialog instead.
- The removal is one row in a menu that needs no confirm. Use a `variant="destructive"` row in DropdownMenu instead.

### Rules
- Follows `rule/dialog-controlled-stays-mounted`.
- `rule/alert-dialog-for-destructive`: When an action deletes, removes or cannot be undone, confirm it in `AlertDialog` instead of Dialog or Popover, because the alert dialog ignores a scrim press and names itself `alertdialog`, so a stray press cannot dismiss the decision (`trap/overlay-destructive`). Evidence: measured a scrim press leaves the popup open and `role="alertdialog"`, .design-system/evidence/alert-dialog/open-390x320.json; principle wcag: 4.1.2 Name, role, value, the role tells a screen reader a decision is waiting. Check: review of every `variant="destructive"` action that asks first.
  - Don't: `<Popover><PopoverTrigger>Delete</PopoverTrigger><PopoverContent><Button variant="destructive">Delete list</Button></PopoverContent></Popover>`
  - Do: `<AlertDialog><AlertDialogTrigger render={<Button variant="destructive" />}>Delete</AlertDialogTrigger><AlertDialogContent><AlertDialogTitle>Delete list</AlertDialogTitle>...</AlertDialogContent></AlertDialog>`
- `rule/alert-dialog-cancel-first`: When the footer holds the cancel and the action, write `AlertDialogCancel` first in `AlertDialogFooter` and the action after it, because focus lands on the first tabbable control on open, so Enter cancels and does not destroy, and the row puts the action on the trailing edge. Evidence: measured focus on Cancel on open, .design-system/evidence/alert-dialog/open-390x320.json; principle platform: the native alert's safe action takes the default. Check: test `alert-dialog.test.tsx` renders Cancel before the action; review of every `AlertDialogFooter`.
  - Don't: `<AlertDialogFooter><AlertDialogAction variant="destructive">Delete list</AlertDialogAction><AlertDialogCancel>Cancel</AlertDialogCancel></AlertDialogFooter>`
  - Do: `<AlertDialogFooter><AlertDialogCancel>Cancel</AlertDialogCancel><AlertDialogAction variant="destructive">Delete list</AlertDialogAction></AlertDialogFooter>`
- `rule/alert-dialog-pending-holds`: When the confirmed action is in flight, pass `status="pending"` to `AlertDialogContent` and render the action as a `StateButton` with `pendingLabel`, instead of closing on click, because Escape and Cancel then do nothing, Cancel keeps focus with `aria-disabled`, and a failure can land on the open dialog (`trap/overlay-pending-dismiss`). Evidence: person D2; measured Escape leaves the pending dialog open, Cancel `aria-disabled="true"`, the popup `aria-busy="true"`, .design-system/evidence/alert-dialog/open-390x320.json. Check: review of every `AlertDialogContent` whose action is async; test `alert-dialog.test.tsx` renders the idle Cancel without `aria-disabled`.
  - Don't: `<AlertDialogAction variant="destructive" onClick={() => { remove(); setOpen(false); }}>Delete list</AlertDialogAction>`
  - Do: `<AlertDialogContent status={status}>...<StateButton variant="destructive" status={status} pendingLabel="Deleting" onClick={remove}>Delete list</StateButton></AlertDialogContent>`
- `rule/alert-dialog-failure-stays`: When the action fails, keep the dialog open, render `AlertDialogError` in the footer and let the `StateButton` settle back to idle after `ERROR_HOLD_MS`, instead of closing and raising a toast, because you are still looking at the decision and retry in place. Evidence: measured the dialog open after failure with the error as `role="alert"` and Cancel enabled again, .design-system/evidence/alert-dialog/open-390x320.json; principle heuristic: help users recognize, diagnose and recover from errors, the error sits where the action was taken. Check: test `alert-dialog.test.tsx` renders `AlertDialogError` with `role="alert"`; review.
  - Don't: `onError={() => { setOpen(false); toast.error("Could not delete"); }}`
  - Do: `<AlertDialogFooter>{failed && <AlertDialogError>The list could not be deleted. Try again.</AlertDialogError>}<AlertDialogCancel>Cancel</AlertDialogCancel><StateButton variant="destructive" status={status} failureLabel="Not deleted">Delete list</StateButton></AlertDialogFooter>`
- `rule/alert-dialog-final-focus`: When a confirmed action removes the thing that opened the dialog, such as a row's menu or the row itself, pass `finalFocus` on `AlertDialogContent` as a function that returns the next row, the list's heading or the list, instead of relying on the trigger, because focus returns to the trigger on close and a trigger that is gone drops focus to the page body, where the next Tab starts from the top of the page. Evidence: measured `document.activeElement` as `body` after confirming a cancel with the keyboard in the bookings scene, `docs/research/2026-10-16-first-principles.md` defect 5; principle wcag: 2.4.3 Focus order, focus lands somewhere meaningful after a close; single use docs/system/examples/blocks/bookings.tsx:595, the cancel confirm that removes its opener passes it. Check: review of every `AlertDialogContent` whose action removes its trigger; probe: confirm with the keyboard, then read `document.activeElement`, which is never `body`.
  - Don't: `<AlertDialogContent status={remove.status}>` with the row and its menu trigger gone after the delete
  - Do: `<AlertDialogContent status={remove.status} finalFocus={() => nextRow.current ?? heading.current}>`

### Content
- Follows `rule/writing-dialog-title-verb`.
- Follows `rule/writing-dialog-body-sentence`.
- Follows `rule/writing-confirm-verb-chain`.
- `rule/alert-dialog-body-names-the-object`: When the description says what is lost, name the object and its real count, such as "The twelve items in it are deleted too.", before "This cannot be undone.", instead of "This action cannot be undone." alone, because the count is what you weigh, and the warning without it is the same on every screen. Evidence: person D11; principle heuristic: help users recognize, diagnose and recover from errors, the consequence is stated in the object's own terms. Check: lint copy/end-punctuation on the dialog-body slot (scripts/copy-check.mjs); review of every `AlertDialogDescription`.
  - Don't: `<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>`
  - Do: `<AlertDialogDescription>The twelve items in it are deleted too. This cannot be undone.</AlertDialogDescription>`

### Anti-slop
- `rule/alert-dialog-no-close-button`: When an alert dialog is built, give it no corner close and no `showCloseButton`, because the two footer actions are the only ways out of a yes or no, and an X is a third answer. Evidence: measured 0 close buttons in the open popup, .design-system/evidence/alert-dialog/open-390x320.json; principle heuristic: aesthetic and minimalist design, one control per answer. Check: lint typecheck, which rejects `showCloseButton` on `AlertDialogContent` (`pnpm typecheck`).
  - Don't: `<AlertDialogContent showCloseButton><AlertDialogTitle>Delete list</AlertDialogTitle></AlertDialogContent>`
  - Do: `<AlertDialogContent><AlertDialogTitle>Delete list</AlertDialogTitle></AlertDialogContent>`
- `rule/alert-dialog-action-written-red`: When the confirmed action destroys, give the action `variant="destructive"`, red text on the wash, instead of a red fill or the accent fill, because the word carries the meaning. Evidence: person D26; person D13. Check: lint rule/component-override on Button (scripts/check-system.mjs); review.
  - Don't: `<AlertDialogAction className="bg-bad text-white">Delete list</AlertDialogAction>`
  - Do: `<AlertDialogAction variant="destructive">Delete list</AlertDialogAction>`

### Limits
- `rule/alert-dialog-body-length`: When the description would run past 158 characters, cut it to two sentences under that, because the 14px body holds 79 characters per line in the 272px column at 390px, and a third line pushes the footer past the 288px max height at 320 tall, where the popup already scrolls 16px. Evidence: measured wrap at 79 characters per line and a scroll height of 304px over 288px at 390 by 320, .design-system/evidence/alert-dialog/open-390x320.json. Check: probe `.design-system/scripts/measure-overlays.mjs` grows the description on the showcase at 390 by 320.
  - Don't: `<AlertDialogDescription>The twelve items in it are deleted too, along with every comment and attachment anyone added, and the people you shared it with lose access at once. This cannot be undone.</AlertDialogDescription>`
  - Do: `<AlertDialogDescription>The twelve items in it are deleted too. This cannot be undone.</AlertDialogDescription>`
- `rule/alert-dialog-title-length`: When a title would run past 36 characters, shorten it instead of letting it wrap, because at 37 characters the 18px title wraps to a second line in the 272px column at 390px. Evidence: measured wrap at 37 characters in a 272px column at 390px, .design-system/evidence/alert-dialog/open-390x320.json. Check: probe `.design-system/scripts/measure-overlays.mjs` grows the title on the showcase at 390.
  - Don't: `<AlertDialogTitle>Delete this list and everything in it?</AlertDialogTitle>`
  - Do: `<AlertDialogTitle>Delete this list?</AlertDialogTitle>`

## Accessibility
Rests on Base UI `AlertDialog`, which renders `role="alertdialog"` with `aria-labelledby` and `aria-describedby`, moves focus to the first control on open and back to the trigger on close, closes on Escape and not on an outside press. Every row that says `a11y scan` was read from the open popup on the live page into `.design-system/evidence/alert-dialog/open-390x320.json`.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Enter or Space | the trigger | opens the dialog | Cancel, the first tabbable control | a11y scan |
| Tab and Shift+Tab | inside the popup | moves between Cancel and the action and wraps; the page behind is inert | the other action | by hand |
| Enter or Space | Cancel | closes without acting; while pending, nothing and Cancel keeps focus | the trigger (`trap/overlay-focus-return`); while pending, Cancel | a11y scan |
| Enter or Space | the action | runs the action; the host closes on success or renders the error on failure | the action while pending, then the trigger on close, or what `finalFocus` returns when the action removed the trigger (rule/alert-dialog-final-focus), or the action on failure | by hand |
| Escape | inside the popup | closes without acting; while pending, nothing | the trigger; while pending, unchanged | a11y scan |
| Escape | inside a menu or popover open within the dialog | closes the menu or popover only (`trap/escape-nested`) | that menu's trigger | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| trigger | button | its text | `aria-haspopup="dialog"`, `aria-expanded`, `data-popup-open` while open (`trap/open-trigger-unfocused`) | the name, "button", "collapsed" or "expanded" | test |
| popup | alertdialog | `aria-labelledby` from `AlertDialogTitle` | `aria-describedby` from `AlertDialogDescription`, `tabindex="-1"`, `aria-busy` while pending, `data-size` | "alert dialog", the title, then the description on open | a11y scan |
| cancel | button | its text | `aria-disabled` while pending | "Cancel, button" on open | a11y scan |
| action | button | its text | `aria-busy` and `aria-disabled` from StateButton while pending | the name and role on focus | test |
| error | alert | its text | none | the sentence as it appears | test |

## Tokens
| Part | State | Token |
|---|---|---|
| popup | all | `--popover`, `--popover-foreground`, `--r-4xl`, `--elev-sheet`, `--gutter`, `--t-arrive`, `--curve` |
| title | all | `--foreground`, measured 19.8 to 1 on `--popover` in `.design-system/evidence/alert-dialog/open-390x320.json` |
| description | all | `--muted-foreground`, measured 6.01 to 1 on `--popover` |
| error | failure | `--destructive`, measured 5.61 to 1 on `--popover` |
| cancel | rest | no fill, `--foreground` text on `--popover` |
| cancel | hover | `--muted` |
| scrim | all | `--scrim`, `--t-arrive` |

## Related
- Dialog: a task with a form, dismissable from the scrim.
- Sheet: a task that scrolls.
- DropdownMenu: where the destructive item that opens this usually lives.
- Toaster: the result, with an undo, when the action needs no question first.
- StateButton: the action that reports pending and failure in place.
- Popover: a small panel beside its trigger, not for a confirm.
- Grow: opens one small answer out of the control that asks for it.
- Alert: a message about the page that needs no answer, shown in place.
