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
CPU
<0.01 ms
02468101216.7 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.
apple · Apple A19 Proin a browser tab · 16 November 2026
not timed
<0.01
0.02
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
not timed
<0.01
0.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
Forms and settings in a modal
Destructive confirmations
Mobile bottom sheets and side panels
Quick one-line prompts
Stacked flows (a confirm over a sheet over a dialog)
Pitfalls, in brief
Import dialog.base.css before dialog.css (or your own look).
Inert covers what is in the host when the dialog opens.
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.
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.
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
Act on the promise, not on clicks: open() resolves with the closing value (undefined when dismissed), confirm() with true only for its confirm button.
beforeClose runs for user closes only (Esc, backdrop, close buttons, swipe), so a Save that calls close(value) is never asked "Discard changes?".
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.
Do not open a dialog from pointerdown if you can help it: the browser moves focus after it.
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.
A small appearance system: colour presets as CSS variables (light, dark, two high-contrast, two accent looks), a “Match system” choice that follows the…