Dialogs
Use a modal for a focused decision, with reliable positioning and a clear path back.
Try the dialog
Field notes
View markup
<div class="spec-stack"><h3 data-title>Field notes</h3>
<div class="spec-actions"><button class="ex-button ex-button--spectral" type="button" data-open>
Open notebook <span class="ex-icon ex-icon--arrow-right" aria-hidden="true"></span></button></div></div>
<dialog class="ex-dialog" id="spec-reader" aria-labelledby="spec-reader-title">
<div class="ex-dialog-header"><h3 id="spec-reader-title" data-title>Field notes</h3></div>
<div class="ex-dialog-body spec-stack"><p>Three leaves on the same branch, sketched on a morning walk.</p>
<p class="spec-muted">Reading status <strong data-reading-state>To read</strong></p></div>
<div class="ex-dialog-actions"><button class="ex-button ex-button--primary" type="button" data-close>Close</button></div>
</dialog>Warning dialogs
Give someone a chance to keep their draft before they leave.
View markup
<div class="atlas-stack" data-ex-recipe="warning-dialogs">
<div class="ex-field"><label class="ex-label" for="atlas-draft">Draft note</label>
<textarea class="ex-input" id="atlas-draft" rows="2" maxlength="280">The harbour at dusk.</textarea></div>
<div class="atlas-actions"><button class="ex-button ex-button--secondary" type="button" data-open>Leave draft</button></div>
<dialog class="ex-dialog" id="atlas-draft-dialog" role="alertdialog"
aria-labelledby="atlas-draft-title" aria-describedby="atlas-draft-reason">
<div class="ex-dialog-body atlas-dialog-copy"><span class="atlas-signal atlas-warning"><span class="ex-icon ex-icon--warning" aria-hidden="true"></span></span>
<h3 id="atlas-draft-title">Leave this draft?</h3><p id="atlas-draft-reason">Leaving clears the unsaved text in this sample.</p></div>
<div class="ex-dialog-actions"><button class="ex-button ex-button--secondary" type="button" data-cancel>Keep editing</button>
<button class="ex-button ex-button--primary" type="button" data-confirm>Leave without saving</button></div>
</dialog>
<p class="atlas-status" role="status"></p>
</div>Use in a projectDestructive confirmations
Name the item and the consequence. Start focus on the safer action.
View markup
<div class="atlas-stack" data-ex-recipe="destructive-dialogs">
<div class="atlas-list-row" data-item><span class="atlas-item-label">Harbour sketches</span>
<button class="ex-button ex-button--danger" type="button" data-open>Delete notebook</button></div>
<p class="atlas-status" role="status"></p>
<div class="atlas-actions" data-restore hidden><button class="ex-button ex-button--secondary" type="button" data-undo>Restore sample notebook</button></div>
<dialog class="ex-dialog" id="atlas-delete-dialog" role="alertdialog"
aria-labelledby="atlas-delete-title" aria-describedby="atlas-delete-reason">
<div class="ex-dialog-body atlas-dialog-copy"><span class="atlas-signal atlas-error"><span class="ex-icon ex-icon--warning" aria-hidden="true"></span></span>
<h3 id="atlas-delete-title">Delete Harbour sketches?</h3><p id="atlas-delete-reason">This removes the sample notebook from this list.</p></div>
<div class="ex-dialog-actions"><button class="ex-button ex-button--secondary" type="button" data-cancel>Keep notebook</button>
<button class="ex-button ex-button--danger" type="button" data-confirm>Delete notebook</button></div>
</dialog>
</div>Use in a projectUsage and implementation
Choose a focused interruption
A dialog suits a short decision or focused edit. A substantial task with direct-link or navigation needs usually belongs on a page. A bottom sheet is a separate responsive pattern, not a misplaced modal.
Centre within the viewport
Use the native dialog with .ex-dialog and showModal(). Keep a 16px viewport gutter, content-led dimensions and a maximum width near 32rem. Long content scrolls inside the dialog. On short screens, the entire dialog may become the scroll surface.
Do not add the open attribute as a substitute for the modal lifecycle. Avoid transforms inherited from surrounding containers or manual top-left positioning.
Focus and interaction
- Name the dialog with its heading through aria-labelledby.
- Choose a useful initial focus target; long reading content may need a focusable heading.
- Keep background content inert and keyboard focus within the modal.
- Escape closes where appropriate; provide a visible close action.
- Return focus to the opener when it still exists, or to a sensible next target.
Check from different scroll positions
Open from the top and after scrolling. Test short and long content, 320px width, intermediate widths, landscape, text enlargement, both themes and a virtual keyboard. Confirm no clipped actions, no background scroll leak and logical focus after closing.
