Dialog
A titled panel that takes focus: modal over an inert page, or non-modal in the page flow. Focus returns to its trigger on close.
Why it's built this way
| Decision | Why |
|---|---|
The description sits at the top of Body, above your content. Header holds only the title and the close button. | Placed on its own between the header and the body, the description looked detached. MUI's dialogs put it inside the content the same way. |
Each section (Header, Body, Actions) has its own padding. The dialog itself pads only the top and bottom. | Body scrolls, which clips anything outside its box. With the padding on the dialog, a focused field at the edge of Body lost its focus ring. |
| The close button lines up with the content edge and sits centred on the title's first line, however many lines the title wraps to. | A small round button has padding around its icon, so without an offset the × sits inside the content edge and above the title text. |
Built on the native <dialog> element, not a div with a JavaScript focus trap. | The browser blocks the rest of the page, handles Escape and draws the dialog above everything, with no z-index. Every major browser has supported this since 2023. |
| Focus stays in the dialog because the page behind it is blocked, not because Tab wraps around. Tab past the last control may reach the browser's own controls before coming back. | This meets WCAG's rules on focus order and keyboard traps (2.4.3, 2.1.2). Wrap-around advice was written for dialogs built from a div. |
On open, focus goes to the first element marked data-autofocus, or else to the title. | React's autoFocus doesn't work here, so the marker lets you choose, for example Cancel in a destructive confirm. Focusing the title announces the dialog first. |
| On close, focus returns to the element that opened the dialog, if it still exists and you haven't moved focus yourself. | The opener may be gone (a menu item closes with its menu), and you may want focus somewhere else, such as the menu button. |
Body isn't made focusable when it scrolls. In Safari, a long Body of plain text can't be scrolled with the keyboard. | Making it focusable would add a Tab stop and a landmark to every long dialog, for one browser. |
Every component follows ADR-025, ADR-026 and ADR-028(states, prop vocabulary, focus indicator); they are not repeated per component.