PrimitivesView source

Dialog

A native modal with browser-managed focus and dismissal.

Installation

Run the source CLI from a Blocks UI checkout. This package is not published to npm.

node packages/cli/index.js add dialog

Or 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.

default

Accessibility & 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.

Compatibility

Standalone verified. EDS markup compatible. Live AEM integration has not been verified.

Edit this example on GitHub

Search documentation

Search the docs, components, and blocks. Use Tab to select a result.