Dialogs
Request a focused decision without losing the surrounding context.
Live preview
HTML
<div class="xsh-row">
<button class="xsh-button" data-xsh-dialog-open="xsh-example-dialog">Open dialog</button>
</div>
<dialog class="xsh-dialog" id="xsh-example-dialog" aria-labelledby="xsh-example-dialog-title">
<div class="xsh-dialog__header">
<h2 class="xsh-dialog__title" id="xsh-example-dialog-title">Publish changes?</h2>
</div>
<div class="xsh-dialog__body">This publishes your current configuration to your team. You can make changes later.</div>
<div class="xsh-dialog__footer">
<button class="xsh-button xsh-button--secondary" data-xsh-dialog-close>Cancel</button>
<button class="xsh-button" data-xsh-dialog-close data-xsh-toast="success" data-xsh-message="Your changes were published.">Publish changes</button>
</div>
</dialog>Installation & markup
Include the local stylesheet and script once on the page, then place the component inside a data-xsh-ui root. The example above works without a build system.
<link rel="stylesheet" href="/dist/xshna-ui.css">
<div data-xsh-ui>
<!-- Add the HTML example above -->
</div>
<script defer src="/dist/xshna-ui.js"></script>Component API
Public classes, attributes and hooks used by this example. Keep the xsh- prefix intact.
| Identifier | Contract |
|---|---|
xsh-dialog | Used by the example markup and component styles or behavior. |
xsh-dialog__header | Used by the example markup and component styles or behavior. |
xsh-dialog__body | Used by the example markup and component styles or behavior. |
xsh-dialog__footer | Used by the example markup and component styles or behavior. |
data-xsh-dialog-open | Used by the example markup and component styles or behavior. |
data-xsh-dialog-close | Used by the example markup and component styles or behavior. |
Accessibility & keyboard
Native dialog.showModal() provides modal semantics, backdrop, focus containment and Escape support. Focus returns to the invoking element on close.
Implementation note. Always add an accessible title via aria-labelledby. Use confirmation dialogs only when the choice has real consequences.
Interaction contract
Behavioral components use the shared delegated runtime; visual-only primitives rely on semantic HTML and CSS. Runtime controls emit bubbling xsh:* CustomEvents; bind application handlers to those events when server persistence, API data or navigation is required.