APG · Dialog (Modal)
Modal dialog
Focus goes in, cannot get out, and comes back to exactly where it started — including when the trigger is destroyed while the dialog is open.
Try each of these with the keyboard alone.
| Tab | Move to the next focusable element inside the dialog. From the last one, wrap to the first. |
|---|---|
| Shift + Tab | Move to the previous element. From the first, wrap to the last. |
| Esc | Close the dialog and return focus to the element that opened it. |
Notes
The alert variant uses role="alertdialog" and points
aria-describedby at the consequence text, so the stakes are
read out with the title rather than found later. The third example has no
focusable content at all — focus moves to the dialog container itself
(tabindex="-1"), which is what makes the title get announced
instead of focus silently staying on the now-inert page behind.
Rename workspace
Delete this project?
All 42 files and the deployment history will be removed. This cannot be undone.
Nothing to focus here
This dialog has no buttons and no fields. Focus is on the dialog itself, so its title is still announced. Press Esc to close.