Feature Library

Accessible dialogs: modal, sheet, confirm

<0.01 CPU ms
A still of the Accessible dialogs: modal, sheet, confirm demo
Still
The live demo starts when it’s in view.Open each kind from the page or the controls · Tab stays inside · Esc closes the top one · drag a sheet’s grip to close

One small dialog core that does the whole job: a modal, side and bottom sheets you can drag away, and awaitable confirm() and prompt().

What it costs a frame

<0.01 ms
GPU
not used
CPU, median
<0.01 ms
CPU, 95th pct
0.01 ms
Draw calls
0
Weight
Light

Measured 7 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 156, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured with the demo opening and closing its dialogs from code, one step every 24 frames: the profile form, the side sheet, the stack of three (dialog, sheet, confirm), the destructive confirm and the bottom sheet. Each open builds or re-shows a layer, makes the page inert, locks its scroll and moves focus; each close gives it all back. Nothing runs between steps. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
unknown GPU · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring toolnot timed<0.010.01
apple · Apple A19 Proin a browser tab · 16 November 2026not timed<0.010.02
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026not timed<0.010.01

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages

What it’s for

  1. Forms and settings in a modal
  2. Destructive confirmations
  3. Mobile bottom sheets and side panels
  4. Quick one-line prompts
  5. Stacked flows (a confirm over a sheet over a dialog)

Pitfalls, in brief

  1. Import dialog.base.css before dialog.css (or your own look).
  2. Inert covers what is in the host when the dialog opens.
  3. A host other than document.body must be positioned (relative, absolute…) and should not scroll: put the scrolling page inside it and pass that as scroller, or the layer scrolls away with the content.
  4. A frosted panel (backdrop-filter) in a host that is itself frosted, or has a filter, mask or opacity under 1, cannot blur what is behind that host: the host is its backdrop root, so the panel shows only what is painted inside the host, and in a see-through card that looks like the page far behind.
  5. Toasts and live regions inside an inert page are silent while a dialog is open: announce from inside the dialog, or from a live region outside the host.
5 more in brief
  1. Act on the promise, not on clicks: open() resolves with the closing value (undefined when dismissed), confirm() with true only for its confirm button.
  2. beforeClose runs for user closes only (Esc, backdrop, close buttons, swipe), so a Save that calls close(value) is never asked "Discard changes?".
  3. position: fixed elements on the page (a sticky bar, a chat bubble) do not know about the kept scrollbar gutter when the html element has no classic scrollbar; with one, scrollbar-gutter: stable keeps them still.
  4. Do not open a dialog from pointerdown if you can help it: the browser moves focus after it.
  5. Opening one inside a full-screen element needs that element as host: the full-screen element hides everything outside it, document.body included.
10 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

Written for the library. Fully custom code.

WAI-ARIA Authoring Practices Guide (W3C): The dialog (modal) and alertdialog patterns: roles and labelling, where focus goes on open and close (a confirm starts on the least destructive choice), Tab kept inside, Esc. Written here from scratch.

dialogmodalbottom sheetconfirmalertdialoginertfocus managementscroll lockaccessibilitykeyboardtouchrtldomcssno dependencies

Near it in the frame