Dialog
A native modal with browser-managed focus and dismissal.
<div class="dialog-example"><button type="button" class="button" data-open-dialog>Open dialog</button><dialog aria-labelledby="example-dialog-title"><h1 id="example-dialog-title" style="font-size:24px">Make it your own.</h1><p class="muted">Native dialogs handle focus, keyboard dismissal, and the backdrop. No extra library needed.</p><form method="dialog" class="dialog-actions"><button class="button-secondary" autofocus>Close dialog</button></form></dialog></div>.dialog-actions { display: flex; justify-content: end; gap: 0.5rem; margin-top: 1.5rem; }export default function decorate(root) {
const dialog = root.querySelector('dialog');
const open = root.querySelector('[data-open-dialog]');
if (!dialog || !open) return;
const handler = () => dialog.showModal();
open.addEventListener('click', handler);
return () => open.removeEventListener('click', handler);
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add dialogOr copy the source files above. Include tokens.css and base.css once in your project.
Usage
Use semantic HTML and the shared foundation styles. Interactive primitives also export a decorate function.
<div class="dialog-example"><button type="button" class="button" data-open-dialog>Open dialog</button><dialog aria-labelledby="example-dialog-title"><h1 id="example-dialog-title" style="font-size:24px">Make it your own.</h1><p class="muted">Native dialogs handle focus, keyboard dismissal, and the backdrop. No extra library needed.</p><form method="dialog" class="dialog-actions"><button class="button-secondary" autofocus>Close dialog</button></form></dialog></div>import decorate from './components/dialog/dialog.js';
decorate(document.querySelector('.dialog-example'));Variants
Choose a variant in the live preview. Add its class to the authored block.
defaultAccessibility & behavior
Native dialog.showModal() provides focus containment, Escape dismissal, and automatic focus restoration. The Close dialog button is initially focused.
Multiple instances are supported. Layouts adapt to smaller viewports. No npm dependencies are required at runtime.
AEM usage
Primitives belong inside authored blocks, not as nested EDS blocks. Copy their styles and markup into the parent block implementation.
Standalone verified. EDS markup compatible. Live AEM integration has not been verified.