Overlay & disclosure

Dialog

Modal presentation built on the platform dialog element and declarative commands.

Canonical sourcepatterns/dialog.html
Behavior ownerNative HTML
Runtime inside FormaNone
Example 1

Canonical

Canonical repository markup, namespaced only to keep examples independent.

Confirm action

The browser owns modal focus, inertness, and Escape behavior.

View HTML
<button type="button" commandfor="ex1-dialog-example-dialog" command="show-modal">Open dialog</button>
<dialog class="ef-dialog" id="ex1-dialog-example-dialog">
  <div class="ef-dialog__body">
    <h2>Confirm action</h2>
    <p>The browser owns modal focus, inertness, and Escape behavior.</p>
  </div>
  <div class="ef-dialog__actions">
    <button type="button" commandfor="ex1-dialog-example-dialog" command="close">Cancel</button>
  </div>
</dialog>
Example 2

Representative state

A browser-native state made visible without adding a runtime.

Confirm action

The browser owns modal focus, inertness, and Escape behavior.

View HTML
<button type="button" commandfor="ex2-dialog-example-dialog" command="show-modal">Open dialog</button>
<dialog open class="ef-dialog" id="ex2-dialog-example-dialog">
  <div class="ef-dialog__body">
    <h2>Confirm action</h2>
    <p>The browser owns modal focus, inertness, and Escape behavior.</p>
  </div>
  <div class="ef-dialog__actions">
    <button type="button" commandfor="ex2-dialog-example-dialog" command="close">Cancel</button>
  </div>
</dialog>
Example 3

Constrained layout

The canonical contract inside a narrow application region.

Confirm action

The browser owns modal focus, inertness, and Escape behavior.

View HTML
<button type="button" commandfor="ex3-dialog-example-dialog" command="show-modal">Open dialog</button>
<dialog class="ef-dialog" id="ex3-dialog-example-dialog">
  <div class="ef-dialog__body">
    <h2>Confirm action</h2>
    <p>The browser owns modal focus, inertness, and Escape behavior.</p>
  </div>
  <div class="ef-dialog__actions">
    <button type="button" commandfor="ex3-dialog-example-dialog" command="close">Cancel</button>
  </div>
</dialog>