# AlertDialog primitive
Source: https://texuli.com/primitives-page/alert-dialog/
# AlertDialog
A modal dialog that interrupts to confirm or cancel an action.
Import
`import * as AlertDialog from '@texuli/primitives/alert-dialog';`
Pattern
[Alert dialog (WAI-ARIA APG)](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/)
Size budget
13.0 KiB gzip for @texuli/primitives/alert-dialog
Reference
`packages/primitives/docs/prim-alert-dialog.md`
## Live demo
Right to left
Loading the AlertDialog demo…
## Anatomy
AlertDialog anatomy: each box holds the parts inside it.
- `AlertDialog.Root``AlertDialog.Trigger`
- `AlertDialog.Portal``AlertDialog.Overlay`
- `AlertDialog.Content``AlertDialog.Title`
- `AlertDialog.Description`
- `AlertDialog.Cancel`
- `AlertDialog.Action`
## Behavior checks
`tests/behavior/scenarios/alert-dialog.spec.ts` runs **8 rows** against the AlertDialog scenario on Chromium, WebKit and the Pixel 7. Each row asserts what a user or assistive technology can observe, held to the WAI-ARIA Authoring Practices pattern.
All 8 rows
- it is an alertdialog named by its title and described
- focus starts on Cancel, the safe choice
- Tab stays on Cancel and Delete
- a pointer press outside does not dismiss it
- Cancel closes it without confirming
- Delete confirms once and closes it
- Escape closes it and focus returns to the trigger
- the page behind it is inert
### Limits
- Every row passes on every project; a flaky row gets at most two retries.
- Size: at most 13.0 KiB gzip for `@texuli/primitives/alert-dialog` (`pnpm size`).
- Open-to-focus: p75 at most 50 ms (asserted with `TEXULI_PERF=1`).
AlertDialog
A modal dialog that interrupts to confirm or cancel an action.
- Import
import * as AlertDialog from '@texuli/primitives/alert-dialog';- Pattern
- Alert dialog (WAI-ARIA APG)
- Size budget
- 13.0 KiB gzip for @texuli/primitives/alert-dialog
- Reference
packages/primitives/ docs/ prim-alert-dialog.md
Loading the AlertDialog demo…
Anatomy
AlertDialog.RootAlertDialog.TriggerAlertDialog.PortalAlertDialog.OverlayAlertDialog.ContentAlertDialog.TitleAlertDialog.DescriptionAlertDialog.CancelAlertDialog.Action
Behavior checks
tests/behavior/scenarios/alert-dialog.spec.ts runs 8 rows against the AlertDialog scenario on Chromium, WebKit and the Pixel 7. Each row asserts what a user or assistive technology can observe, held to the WAI-ARIA Authoring Practices pattern.
All 8 rows
- it is an alertdialog named by its title and described
- focus starts on Cancel, the safe choice
- Tab stays on Cancel and Delete
- a pointer press outside does not dismiss it
- Cancel closes it without confirming
- Delete confirms once and closes it
- Escape closes it and focus returns to the trigger
- the page behind it is inert
Limits
- Every row passes on every project; a flaky row gets at most two retries.
- Size: at most 13.0 KiB gzip for
@texuli/primitives/alert-dialog(pnpm size). - Open-to-focus: p75 at most 50 ms (asserted with
TEXULI_PERF=1).