overlayshwcz-drawer

Drawer

Panel sliding in from a screen edge with a drag handle, swipe-to-dismiss, and offcanvas-style presentations.

Attributes

AttributeTypeDefaultDescription
placementDrawerPlacement'bottom'Edge the drawer slides from: bottom (default), top, left, or right.
no-handlebooleanfalseHides the drag handle bar.
no-swipebooleanfalseDisables drag/swipe dismissal.
blurbooleanfalseApplies a backdrop blur to the overlay.
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:drawer · defaultstl target:drawer

KeyDefault classclsstlDescription
contentz-drawer-contentyesyesThe scrollable content region inside the panel (default z-drawer-content).
drawerz-draweryesyesThe sliding panel (default z-drawer); the default cls/stl target.
handlez-drawer-handleyesyesThe drag-handle hit area at the panel's outer edge (default z-drawer-handle).
handle-barz-drawer-handle-baryesyesThe visible handle pill inside the hit area (default z-drawer-handle-bar).
overlayz-modal z-drawer-overlayyesyesThe backdrop overlay (default z-modal z-drawer-overlay).

CSS Variables

VariableDefaultScopeDescription
--z-drawer-bgvar(--z-bg).z-drawerBackground color of the panel.
--z-drawer-border-colorvar(--z-border).z-drawerBorder base color, mixed with transparency using --z-drawer-border-color-o.
--z-drawer-border-color-ovar(--z-border-o).z-drawerBorder opacity percentage used in the border color mix.
--z-drawer-border-width1px.z-drawerBorder width on the panel's inner edge.
--z-drawer-colorvar(--z-bg-f).z-drawerText color of the panel.
--z-drawer-handle-bgvar(--z-border).z-drawerHandle base color, mixed with transparency using --z-drawer-handle-bg-o.
--z-drawer-handle-bg-ocalc(var(--z-border-o) * 1.25).z-drawerHandle opacity percentage used in the color mix.
--z-drawer-handle-hover-bg-ocalc(var(--z-border-o) * 2.25).z-drawerHandle opacity percentage while hovered.
--z-drawer-handle-length5rem.z-drawerLength of the handle pill.
--z-drawer-handle-radius9999px.z-drawerCorner radius of the handle pill.
--z-drawer-handle-thickness0.375rem.z-drawerThickness of the handle pill.
--z-drawer-max-height85dvh.z-drawerMaximum height of top/bottom drawers.
--z-drawer-max-widthcalc(100vw - 2rem).z-drawerMaximum width of left/right drawers.
--z-drawer-radiuscalc(var(--z-global-radius) * 2).z-drawerCorner radius of the panel's outer corners.
--z-drawer-shadow0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1).z-drawerBox shadow of the panel.
--z-drawer-side-radius0px.z-drawerCorner radius applied on the placement side.
--z-drawer-transitiontransform 0.15s cubic-bezier(0.16, 1, 0.3, 1).z-drawerTransition timing of the panel slide.
--z-drawer-width24rem.z-drawerWidth of left/right drawers.
--z-offcanvas-bar-border-width1px.z-offcanvas-barBorder width of the offcanvas bar's inner edge.
--z-offcanvas-bar-transitionleft 0.3s ease-out.z-offcanvas-barTransition of the offcanvas bar slide.
--z-offcanvas-bar-width288px.z-offcanvasWidth of the offcanvas bar.
--z-offcanvas-container-transitionleft 0.3s ease-out.z-offcanvas-containerTransition of the pushed page container.
--z-offcanvas-overlay-bg#000.z-offcanvas-overlayOffcanvas backdrop base color, mixed with transparency using --z-offcanvas-overlay-bg-o.
--z-offcanvas-overlay-bg-o80%.z-offcanvas-overlayBackdrop opacity percentage used in the background mix.
--z-offcanvas-overlay-blurvar(--z-global-blur).z-offcanvas-overlayBackdrop blur radius of the offcanvas overlay.
--z-offcanvas-overlay-opacity1.z-offcanvas-overlayFinal opacity of the backdrop when open.
--z-offcanvas-overlay-transitionopacity 0.15s linear.z-offcanvas-overlayTransition of the backdrop opacity.
--z-offcanvas-reveal-transitionwidth 0.3s ease-out.z-offcanvas-revealTransition of the reveal wrapper's width.
--z-offcanvas-z-index1000.z-offcanvasStacking order of the offcanvas overlay.

Events

EventDetailFlagsDescription
z-drawer:before-hide · from DialogMixin—cancelable, bubblesFires before closing; call preventDefault() to abort.
z-drawer:before-show · from DialogMixin—cancelable, bubblesFires before opening; call preventDefault() to abort.
z-drawer:destroy · from DialogMixin—bubblesFires when the mounted DOM is removed, via unmount or destroy().
z-drawer:hidden · from DialogMixin—bubblesFires after the close transition completes and focus is restored to the opener.
z-drawer:hide · from DialogMixin—bubblesFires when the dialog starts closing.
z-drawer:mount · from DialogMixin—bubblesFires once when the dialog DOM is first mounted.
z-drawer:show · from DialogMixin—bubblesFires when the dialog starts opening, before the transition completes.
z-drawer: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-partcontent, drawer, handle, overlaydescendantmarkerMarks adopted server-rendered structure: overlay, drawer, handle, and content.
data-reactive · from Hwc—descendantconfigOpts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates.
data-side—descendantmarkerSet by the component to the resolved placement; selects the edge-specific styling.
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-drawerrootz-drawerRoot class of the sliding panel.
.z-drawer-contentstate.z-drawerScrollable content region of the panel.
.z-drawer-handlestate.z-drawerDrag-handle hit area along the panel's outer edge.
.z-drawer-handle-barstate.z-drawerThe visible handle pill.
.z-drawer-overlayelement.z-drawerThe drawer's backdrop overlay.
.z-offcanvaselement.z-drawerFixed side-bar overlay root (offcanvas presentation).
.z-offcanvas-barelement.z-drawerThe sliding side bar itself.
.z-offcanvas-bar-animationelement.z-drawerEnables the bar's slide transition.
.z-offcanvas-containerelement.z-drawerPage container that can be pushed aside by the bar.
.z-offcanvas-container-animationmodifier.z-drawerPushes the container by the bar width while open.
.z-offcanvas-flipmodifier.z-drawerMirrors the offcanvas to the right edge.
.z-offcanvas-overlayelement.z-drawerOverlay presentation: dims the page behind the bar.
.z-offcanvas-pageelement.z-drawerPage root class clipping horizontal overflow while an offcanvas is open.
.z-offcanvas-revealelement.z-drawerReveal presentation: the bar's wrapper grows in width instead of sliding.

Accessibility

PartARIADescription
content—Scrollable content region; no ARIA attributes.
draweraria-label="${ifDefined(aria.ariaLabel)}" aria-labelledby="${ifDefined(aria.labelledBy)}" aria-modal="true" role="${aria.role}"Sliding panel: aria-modal="true" with the configured dialog/alertdialog role, named via aria-label or aria-labelledby.
handlearia-hidden="true"Drag-handle hit area, aria-hidden="true" (decorative; the panel itself is draggable).
handle-bar—Visual handle pill; no ARIA attributes.
overlay—Backdrop wrapper; no ARIA attributes of its own.
  • Shares the dialog accessibility model: modal panel with the configured role, focus moved in on open and restored to the opener on close.
  • Swipe dismissal ignores interactive content and scrollable regions that can still scroll toward the dismiss direction.