overlayshwcz-dialog

Dialog

Modal dialog with a backdrop overlay, centered/contained/full presentations, focus management, and stacked overlays.

Attributes

Inherited from DialogMixin
AttributeTypeDefaultDescription
openboolean · reflectsfalseOpens the dialog on first render and stays in sync with show() and hide().
centerbooleanfalseVertically centers the panel within the overlay.
containerbooleanfalseAdds z-modal-container to the overlay for a contained presentation.
fullbooleanfalseAdds z-modal-full to the overlay for a full-screen presentation.
stackbooleanfalseKeeps other open dialogs open; without it, showing this dialog hides them. Stacked overlays receive increasing z-index.
inlinebooleanfalseKeeps the component in its original DOM position instead of teleporting it to document.body.
no-bg-closebooleanfalseDisables closing when the overlay background is clicked.
no-esc-closebooleanfalseDisables closing with the Esc key.
unmountbooleanfalseRemoves the rendered DOM after the close transition; the next show mounts it again.
dialog-role'dialog' | 'alertdialog''dialog'ARIA role of the panel: dialog or alertdialog.
aria-labelstring''Accessible name for the panel when no aria-labelledby is set.
aria-labelledbystring''Id of the element that names the panel; takes precedence over aria-label.
Inherited from Hwc
AttributeTypeDefaultDescription
i18nstring''Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults.
floatingstring''Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs.
force-prevent-rerenderbooleanfalseSkips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM.
templatestring''Selector or id of an external element or <template> whose inner content is cloned in place of an inline template[data-fn="template"] child.
Inherited from Base
AttributeTypeDefaultDescription
clsstring''Adds classes to named parts as key: classes pairs; a plain string targets the default part.
stlstring''Adds inline styles to named parts as key: styles pairs; a plain string targets the default part.

Custom Styling (cls / stl)

Default cls target:dialog · defaultstl target:dialog

KeyDefault classclsstlDescription
dialogz-modal-dialogyesyesThe dialog panel inside the overlay (default z-modal-dialog); the default cls/stl target.
overlayz-modalyesyesThe fixed backdrop covering the viewport (default z-modal).

CSS Variables

VariableDefaultScopeDescription
--z-modal-dialog-border-colorvar(--z-border).z-modal-dialogBorder base color, mixed with transparency using --z-modal-dialog-border-color-o.
--z-modal-dialog-border-color-ovar(--z-border-o).z-modal-dialogBorder opacity percentage used in the border color mix.
--z-modal-dialog-border-width1px.z-modal-dialogBorder width of the panel.
--z-modal-dialog-transformscale(0.96).z-modal-dialogInitial transform of the closed panel (animated to identity on open).
--z-modal-dialog-transition0.12s cubic-bezier(0.16, 1, 0.3, 1).z-modal-dialogTransition timing of the panel opacity/transform.
--z-modal-dialog-width32rem.z-modal-dialogWidth of the dialog panel (max 100% of the overlay).
--z-modal-overlay-bg#000.z-modalBackdrop base color, mixed with transparency using --z-modal-overlay-bg-o.
--z-modal-overlay-bg-o80%.z-modalBackdrop opacity percentage used in the background mix.
--z-modal-overlay-blurvar(--z-global-blur).z-modalBackdrop blur radius used by .z-modal-blur.
--z-modal-padding1rem.z-modalBase padding shared by the overlay and panel sections.
--z-modal-padding-bodyvar(--z-modal-padding).z-modalPadding of the body section.
--z-modal-padding-bottom-scrollable0.z-modalBottom padding of a scrollable body directly after the header.
--z-modal-padding-footervar(--z-modal-padding).z-modalPadding of the footer section.
--z-modal-padding-headervar(--z-modal-padding).z-modalPadding of the header section.
--z-modal-padding-top-after-header0.z-modalTop padding of a footer that follows a header (no body between).
--z-modal-padding-top-after-scrollablevar(--z-modal-padding).z-modalTop padding of a footer directly after a scrollable body.
--z-modal-padding-top-between0.z-modalTop padding of a section directly following another section.
--z-modal-radiusvar(--z-global-radius).z-modalCorner radius of the dialog panel.
--z-modal-title-line-height1.z-modal-titleLine height of the dialog title.
--z-modal-title-size1.125rem.z-modal-titleFont size of the dialog title.
--z-modal-title-tracking-0.025em.z-modal-titleLetter spacing of the dialog title.
--z-modal-title-weight600.z-modal-titleFont weight of the dialog title.
--z-modal-transitionopacity 0.12s cubic-bezier(0.16, 1, 0.3, 1).z-modalTransition of the overlay opacity.
--z-modal-z-index1010.z-modalStacking order of the overlay.

Events

EventDetailFlagsDescription
z-dialog:before-hide · from DialogMixin—cancelable, bubblesFires before closing; call preventDefault() to abort.
z-dialog:before-show · from DialogMixin—cancelable, bubblesFires before opening; call preventDefault() to abort.
z-dialog:destroy · from DialogMixin—bubblesFires when the mounted DOM is removed, via unmount or destroy().
z-dialog:hidden · from DialogMixin—bubblesFires after the close transition completes and focus is restored to the opener.
z-dialog:hide · from DialogMixin—bubblesFires when the dialog starts closing.
z-dialog:mount · from DialogMixin—bubblesFires once when the dialog DOM is first mounted.
z-dialog:show · from DialogMixin—bubblesFires when the dialog starts opening, before the transition completes.
z-dialog:shown · from DialogMixin—bubblesFires after the open transition completes.

Methods

SignatureDescription
destroy(removeHost?: boolean = false): Promise<void>Closes and unmounts the dialog DOM; optionally removes the host element as well.
hide(): Promise<void>Closes the dialog and restores focus to the opener.
show(trigger?: HTMLElement | null): Promise<void>Opens the dialog; the trigger element receives focus back on close.
toggle(trigger?: HTMLElement | null): Promise<void>Opens the dialog if closed, otherwise closes it.

Data Hooks

AttributeValuesApplies toRoleDescription
data-close · from DialogMixin—external-triggertriggerClicking the element closes the dialog matched by the selector (usually #id).
data-host-inner · from Hwc—descendantconfigMarks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering.
data-open · from DialogMixin—external-triggertriggerClicking the element opens the dialog matched by the selector without toggling.
data-partdialog, overlaydescendantmarkerMarks the overlay and panel in adopted server-rendered DOM: data-part="overlay" and data-part="dialog".
data-reactive · from Hwc—descendantconfigOpts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates.
data-toggle · from DialogMixin—external-triggertriggerClicking the element toggles the dialog matched by the selector (usually #id).

Child Content

script[data-fn="config"][type="application/json"]

JSON configuration script parsed by the base class (i18n, cls, stl, floating).

AttributeRequiredTypeDescription
data-fnyesconfigMarks the script as configuration (value: config).
data-reactivenobooleanRe-parses the configuration when the script mutates.

select[data-fn="data-source"]

Hidden select parsed into grouped option data by the base class.

AttributeRequiredTypeDescription
data-fnyesdata-sourceMarks the select as the data source (value: data-source).
data-reactivenobooleanRe-parses the options when the select mutates.

optgroup · repeatable

Groups options under a label.

AttributeRequiredTypeDescription
labelyesstringGroup header text; also the default group key.
disablednobooleanDisables every option in the group.
data-keynostringOverrides the group key used in the parsed data.
data-keywordsnocomma-separated stringComma-separated keywords stored with the group's data.

option · repeatable

One option entry within the group.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated; searched alongside the label and value.

option · repeatable

One ungrouped option entry.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated.

template[data-fn="icons"]

Instance-level icon repository.

AttributeRequiredTypeDescription
data-fnyesiconsMarks the template as an icon source (value: icons).
data-reactivenobooleanRe-parses the icons when the template mutates.

* · repeatable

One icon element.

AttributeRequiredTypeDescription
data-keyyesstringIcon key referenced by $icons.

template[data-fn="template"]

Deferred content template mounted by the base class.

AttributeRequiredTypeDescription
data-fnyestemplateMarks the template for deferred mounting (value: template).
data-reactivenobooleanRe-parses the template when it mutates.

CSS Classes

ClassRoleApplies toDescription
.z-modalrootz-dialogOverlay root: fixed, scrollable backdrop with the dimmed background.
.z-modal-blurmodifier.z-modalApplies a backdrop blur to the overlay.
.z-modal-bodyelement.z-modalPanel body section with its own padding.
.z-modal-containerelement.z-modalContained presentation: widens the panel to a large fixed width.
.z-modal-dialogstate.z-modalThe dialog panel: centered, bordered, rounded card that scales/fades in.
.z-modal-footerelement.z-modalPanel footer section with its own padding.
.z-modal-fullelement.z-modalFull-screen presentation: no overlay padding, panel fills the viewport.
.z-modal-headerelement.z-modalPanel header section with its own padding.
.z-modal-pageelement.z-modalApplied to the page root to clip page scroll while the dialog is open.
.z-modal-titleelement.z-modalDialog title typography (size, weight, tracking).

Accessibility

PartARIADescription
dialogaria-label="${ifDefined(aria.ariaLabel)}" aria-labelledby="${ifDefined(aria.labelledBy)}" aria-modal="true" role="${aria.role}"Dialog panel: aria-modal="true" with the configured dialog/alertdialog role, named via aria-label or aria-labelledby.
overlay—Backdrop wrapper; no ARIA attributes of its own.
  • The panel is aria-modal="true" with the configured dialog/alertdialog role; focus moves into the panel on open and back to the opener on close.
  • Structure panel content with .z-modal-header, .z-modal-body, and .z-modal-footer; give the dialog an accessible name via aria-label or aria-labelledby.