Modal Dialog
Blocks everything else, which is why it should be reserved for things that genuinely cannot wait.
Definition
A modal dialog interrupts the current task and prevents interaction with the rest of the page until it is dismissed. That interruption is its cost and its only justification.
Craft convention. True because the industry converged on it. Breaking it costs familiarity, not correctness.
The accessibility contract
- Move focus into the dialog when it opens, usually to the heading or the first control.
- Trap focus inside while it is open.
- Return focus to the triggering element on close.
- Escape closes it, unless closing would lose data, in which case confirm.
- Mark it with role dialog and aria-modal, and give it an accessible name from its heading.
- Make content behind it inert, so it is not reachable by keyboard or exposed to assistive technology.
- The native dialog element with showModal handles most of this, including the top layer.
Sources
Where a source establishes something narrower than the popular reading of it, the note says so.
W3C, ARIA Authoring Practices Guide
Continue from here
Each link says what the connection is, so you can tell a principle from an alternative from a thing people mix this up with.
Applies when you are designing
Principles behind this
The reasoning this solution is an application of.
- User Control and FreedomHeuristic
- FlowPsychology
- ElevationUI foundation
- Figure and GroundUI foundation
Depends on
Get these right first, or this one will not hold.
- Focus ManagementAccessibility
- Keyboard NavigationAccessibility
Often used with
These usually appear in the same screen or the same decision.
- PopoverComponent
- Command PalettePattern
- ConfirmationPattern
- NotificationsPattern
Alternative approach
A different answer to the same problem, with a different cost.
- Drawer and SheetComponent
Both interrupt. A drawer keeps the context visible behind it.
Related concept
Connected closely enough to change how you apply this.
- Confirmation and Destructive CopyUX writing