qds-dialog provides a native modal surface for focused workflows. It uses
HTMLDialogElement.showModal(): background content is inert and the surface
escapes clipping ancestors without moving application DOM.
<script type="module" src="/assets/components/dialog/qds-dialog.js"></script>
<qds-dialog id="review" label="Review changes">
<p>Check the changes before saving.</p>
<div slot="footer"><button type="button" id="save">Save</button></div>
</qds-dialog>
<script type="module">
document.querySelector('#save').onclick = () => review.close('saved');
review.show();
</script>
label supplies the visible title fallback. Alternatively provide slot="title".slot="body" fills the body; slot="footer" holds actions.scroll="dialog" scrolls the entire surface.dialog, title, body, footer, and close.--qds-dialog-width, --qds-dialog-radius, and --qds-dialog-backdrop
customize this surface without changing base tokens.open reflects visibility. show(invoker?) opens; close(value?, reason?)
closes programmatically and saves returnValue.requestClose(reason?, value?) emits cancelable before-close. Prevent that
event to preserve unsaved changes. Direct close() and external open=false
remain authoritative application actions.no-escape or busy is present.close-on-backdrop and requires pointer-down
and click outside the surface. A drag that starts in the content does not close it.hide-close removes the header close button. Always provide a visible footer
action in that case. nonmodal opts out of modality, scroll locking and focus containment.open and close events bubble across shadow boundaries. close.detail
includes { reason, returnValue }.The title receives initial focus so long content begins at its heading. Set
initialFocus to an element, or use autofocus, for a shorter workflow.
Tab and Shift+Tab stay within the active modal, including slotted controls with
open shadow roots. Closing returns focus to the invoker; set returnFocus to a
logical successor when the invoker will be removed. Nested dialogs retain the
outer scroll lock and focus scope.
For a pointer-triggered workflow, call dialog.show(event.currentTarget) from
the trigger’s click handler. This preserves the logical invoker in browsers
where clicking a button does not focus it. Programmatic opening without an
invoker captures the currently focused element.
runAction(async signal => ..., 'saved') sets busy, prevents user dismissal,
and closes on success. Returning false keeps the dialog open. Rejection leaves
it open, announces the error, and emits action-error with the original error.
Its AbortSignal aborts on close or removal. Disable custom action buttons while
busy; repeated runAction calls are rejected while an action is pending.
import { confirmDialog } from '/assets/components/dialog/confirm-dialog.js';
const confirmed = await confirmDialog({
title: 'Archive report?',
message: 'This report will leave the active list.',
confirmLabel: 'Archive',
destructive: true,
onConfirm: async signal => archiveReport({ signal })
});
The helper uses text-only title/message values, focuses Cancel, cleans up after
closing, and resolves to a boolean. A failed action stays open for retry.
Provide container when composing inside an existing modal and returnFocus
for the logical destination (including pointer-triggered workflows).
Use modern browsers supporting native dialog. Existing select and date-picker panels remain descendants of the modal and participate in its focus order. The new shared overlay helpers do not change those controls’ established APIs.
See the demo for slots, nested dialogs, scrolling, async retries, and confirmation composition.