modal dialog
A window laid over the page that users must deal with before returning to the page beneath, with role="dialog" and aria-modal="true".
In more detail
A modal dialog needs an accessible name (usually aria-labelledby pointing at its heading), a focus trap, focus restoration on close, dismissal with Escape, and an inert background. Standard dialogs may close on a backdrop click; alert dialogs may not. HTML's native <dialog> element with showModal() provides much of this.
Examples
In the browser: An accessible modal traps keyboard focus inside itself, closes with Escape and returns focus to the control that opened it. The native dialog element opened with showModal() does all three.React modals are usually rendered through a portal so parent CSS cannot clip them.Related terms
- alertdialog — The ARIA role for a modal dialog that interrupts the user with an urgent message needing a response, such as confirming a deletion.
- focus trap — Code that keeps keyboard focus inside a container, such as an open modal, wrapping from the last element back to the first.
- aria-modal — An ARIA property on a dialog saying that content outside it is not available while it is open.
- backdrop — The dimmed layer behind a modal overlay that covers the rest of the page.
- inert attribute — An HTML attribute that makes an element and everything inside it unclickable, unfocusable and hidden from assistive technology.
- dialog element — The native HTML element for dialogs; opened with showModal() it becomes an accessible modal with a backdrop and focus containment.
- portal — A React feature, createPortal, that renders a component's children into a different place in the DOM, usually document.body.
- ARIA — The W3C standard of HTML attributes, such as role and aria-expanded, that tell assistive technology what a custom widget is and what state it is in.
Taught in
- Component API Ergonomics: Composition vs Boolean Config Props — Design Systems & Component Engineering
- Overlay Architecture: Portals, Stacking Contexts & Backdrops — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- Modal Dialogs & Alert Dialogs: Accessible Overlay Patterns — Design Systems & Component Engineering
- Modern DOM Querying: querySelector, closest And matches — Frontend Architecture & Web Platform
- Pointer Events, Focus Trapping And Keyboard Accessibility — Frontend Architecture & Web Platform
- SyntheticEvent System: Event Delegation in Modern React — React 19 & Modern Component Architecture
- Slot Patterns And Headless UI Architecture in React — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture
- Code-Splitting with React.lazy: Dynamic Imports And Chunks — React 19 & Modern Component Architecture
- React Portals: Escaping Stacking Contexts for Modals — React 19 & Modern Component Architecture
- Accessible Headless Primitives: ARIA, Focus, And Keyboard — React 19 & Modern Component Architecture