overlayshwc
z-drawerDrawer
Panel sliding in from a screen edge with a drag handle, swipe-to-dismiss, and offcanvas-style presentations.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
placement | DrawerPlacement | 'bottom' | Edge the drawer slides from: bottom (default), top, left, or right. |
no-handle | boolean | false | Hides the drag handle bar. |
no-swipe | boolean | false | Disables drag/swipe dismissal. |
blur | boolean | false | Applies a backdrop blur to the overlay. |
Inherited from DialogMixin
| Attribute | Type | Default | Description |
|---|---|---|---|
open | boolean · reflects | false | Opens the dialog on first render and stays in sync with show() and hide(). |
center | boolean | false | Vertically centers the panel within the overlay. |
container | boolean | false | Adds z-modal-container to the overlay for a contained presentation. |
full | boolean | false | Adds z-modal-full to the overlay for a full-screen presentation. |
stack | boolean | false | Keeps other open dialogs open; without it, showing this dialog hides them. Stacked overlays receive increasing z-index. |
inline | boolean | false | Keeps the component in its original DOM position instead of teleporting it to document.body. |
no-bg-close | boolean | false | Disables closing when the overlay background is clicked. |
no-esc-close | boolean | false | Disables closing with the Esc key. |
unmount | boolean | false | Removes 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-label | string | '' | Accessible name for the panel when no aria-labelledby is set. |
aria-labelledby | string | '' | Id of the element that names the panel; takes precedence over aria-label. |
Inherited from Hwc
| Attribute | Type | Default | Description |
|---|---|---|---|
i18n | string | '' | Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults. |
floating | string | '' | Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs. |
force-prevent-rerender | boolean | false | Skips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM. |
template | string | '' | 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
| Attribute | Type | Default | Description |
|---|---|---|---|
cls | string | '' | Adds classes to named parts as key: classes pairs; a plain string targets the default part. |
stl | string | '' | 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
| Key | Default class | cls | stl | Description |
|---|---|---|---|---|
content | z-drawer-content | yes | yes | The scrollable content region inside the panel (default z-drawer-content). |
drawer | z-drawer | yes | yes | The sliding panel (default z-drawer); the default cls/stl target. |
handle | z-drawer-handle | yes | yes | The drag-handle hit area at the panel's outer edge (default z-drawer-handle). |
handle-bar | z-drawer-handle-bar | yes | yes | The visible handle pill inside the hit area (default z-drawer-handle-bar). |
overlay | z-modal z-drawer-overlay | yes | yes | The backdrop overlay (default z-modal z-drawer-overlay). |
CSS Variables
| Variable | Default | Scope | Description |
|---|---|---|---|
--z-drawer-bg | var(--z-bg) | .z-drawer | Background color of the panel. |
--z-drawer-border-color | var(--z-border) | .z-drawer | Border base color, mixed with transparency using --z-drawer-border-color-o. |
--z-drawer-border-color-o | var(--z-border-o) | .z-drawer | Border opacity percentage used in the border color mix. |
--z-drawer-border-width | 1px | .z-drawer | Border width on the panel's inner edge. |
--z-drawer-color | var(--z-bg-f) | .z-drawer | Text color of the panel. |
--z-drawer-handle-bg | var(--z-border) | .z-drawer | Handle base color, mixed with transparency using --z-drawer-handle-bg-o. |
--z-drawer-handle-bg-o | calc(var(--z-border-o) * 1.25) | .z-drawer | Handle opacity percentage used in the color mix. |
--z-drawer-handle-hover-bg-o | calc(var(--z-border-o) * 2.25) | .z-drawer | Handle opacity percentage while hovered. |
--z-drawer-handle-length | 5rem | .z-drawer | Length of the handle pill. |
--z-drawer-handle-radius | 9999px | .z-drawer | Corner radius of the handle pill. |
--z-drawer-handle-thickness | 0.375rem | .z-drawer | Thickness of the handle pill. |
--z-drawer-max-height | 85dvh | .z-drawer | Maximum height of top/bottom drawers. |
--z-drawer-max-width | calc(100vw - 2rem) | .z-drawer | Maximum width of left/right drawers. |
--z-drawer-radius | calc(var(--z-global-radius) * 2) | .z-drawer | Corner radius of the panel's outer corners. |
--z-drawer-shadow | 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1) | .z-drawer | Box shadow of the panel. |
--z-drawer-side-radius | 0px | .z-drawer | Corner radius applied on the placement side. |
--z-drawer-transition | transform 0.15s cubic-bezier(0.16, 1, 0.3, 1) | .z-drawer | Transition timing of the panel slide. |
--z-drawer-width | 24rem | .z-drawer | Width of left/right drawers. |
--z-offcanvas-bar-border-width | 1px | .z-offcanvas-bar | Border width of the offcanvas bar's inner edge. |
--z-offcanvas-bar-transition | left 0.3s ease-out | .z-offcanvas-bar | Transition of the offcanvas bar slide. |
--z-offcanvas-bar-width | 288px | .z-offcanvas | Width of the offcanvas bar. |
--z-offcanvas-container-transition | left 0.3s ease-out | .z-offcanvas-container | Transition of the pushed page container. |
--z-offcanvas-overlay-bg | #000 | .z-offcanvas-overlay | Offcanvas backdrop base color, mixed with transparency using --z-offcanvas-overlay-bg-o. |
--z-offcanvas-overlay-bg-o | 80% | .z-offcanvas-overlay | Backdrop opacity percentage used in the background mix. |
--z-offcanvas-overlay-blur | var(--z-global-blur) | .z-offcanvas-overlay | Backdrop blur radius of the offcanvas overlay. |
--z-offcanvas-overlay-opacity | 1 | .z-offcanvas-overlay | Final opacity of the backdrop when open. |
--z-offcanvas-overlay-transition | opacity 0.15s linear | .z-offcanvas-overlay | Transition of the backdrop opacity. |
--z-offcanvas-reveal-transition | width 0.3s ease-out | .z-offcanvas-reveal | Transition of the reveal wrapper's width. |
--z-offcanvas-z-index | 1000 | .z-offcanvas | Stacking order of the offcanvas overlay. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-drawer:before-hide · from DialogMixin | — | cancelable, bubbles | Fires before closing; call preventDefault() to abort. |
z-drawer:before-show · from DialogMixin | — | cancelable, bubbles | Fires before opening; call preventDefault() to abort. |
z-drawer:destroy · from DialogMixin | — | bubbles | Fires when the mounted DOM is removed, via unmount or destroy(). |
z-drawer:hidden · from DialogMixin | — | bubbles | Fires after the close transition completes and focus is restored to the opener. |
z-drawer:hide · from DialogMixin | — | bubbles | Fires when the dialog starts closing. |
z-drawer:mount · from DialogMixin | — | bubbles | Fires once when the dialog DOM is first mounted. |
z-drawer:show · from DialogMixin | — | bubbles | Fires when the dialog starts opening, before the transition completes. |
z-drawer:shown · from DialogMixin | — | bubbles | Fires after the open transition completes. |
Methods
| Signature | Description |
|---|---|
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
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-close · from DialogMixin | — | external-trigger | trigger | Clicking the element closes the dialog matched by the selector (usually #id). |
data-host-inner · from Hwc | — | descendant | config | Marks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering. |
data-open · from DialogMixin | — | external-trigger | trigger | Clicking the element opens the dialog matched by the selector without toggling. |
data-part | content, drawer, handle, overlay | descendant | marker | Marks adopted server-rendered structure: overlay, drawer, handle, and content. |
data-reactive · from Hwc | — | descendant | config | Opts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates. |
data-side | — | descendant | marker | Set by the component to the resolved placement; selects the edge-specific styling. |
data-toggle · from DialogMixin | — | external-trigger | trigger | Clicking 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).
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | config | Marks the script as configuration (value: config). |
data-reactive | no | boolean | Re-parses the configuration when the script mutates. |
select[data-fn="data-source"]
Hidden select parsed into grouped option data by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | data-source | Marks the select as the data source (value: data-source). |
data-reactive | no | boolean | Re-parses the options when the select mutates. |
optgroup · repeatable
Groups options under a label.
| Attribute | Required | Type | Description |
|---|---|---|---|
label | yes | string | Group header text; also the default group key. |
disabled | no | boolean | Disables every option in the group. |
data-key | no | string | Overrides the group key used in the parsed data. |
data-keywords | no | comma-separated string | Comma-separated keywords stored with the group's data. |
option · repeatable
One option entry within the group.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated; searched alongside the label and value. |
option · repeatable
One ungrouped option entry.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated. |
template[data-fn="icons"]
Instance-level icon repository.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | icons | Marks the template as an icon source (value: icons). |
data-reactive | no | boolean | Re-parses the icons when the template mutates. |
* · repeatable
One icon element.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-key | yes | string | Icon key referenced by $icons. |
template[data-fn="template"]
Deferred content template mounted by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | template | Marks the template for deferred mounting (value: template). |
data-reactive | no | boolean | Re-parses the template when it mutates. |
CSS Classes
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-drawer | root | z-drawer | Root class of the sliding panel. |
.z-drawer-content | state | .z-drawer | Scrollable content region of the panel. |
.z-drawer-handle | state | .z-drawer | Drag-handle hit area along the panel's outer edge. |
.z-drawer-handle-bar | state | .z-drawer | The visible handle pill. |
.z-drawer-overlay | element | .z-drawer | The drawer's backdrop overlay. |
.z-offcanvas | element | .z-drawer | Fixed side-bar overlay root (offcanvas presentation). |
.z-offcanvas-bar | element | .z-drawer | The sliding side bar itself. |
.z-offcanvas-bar-animation | element | .z-drawer | Enables the bar's slide transition. |
.z-offcanvas-container | element | .z-drawer | Page container that can be pushed aside by the bar. |
.z-offcanvas-container-animation | modifier | .z-drawer | Pushes the container by the bar width while open. |
.z-offcanvas-flip | modifier | .z-drawer | Mirrors the offcanvas to the right edge. |
.z-offcanvas-overlay | element | .z-drawer | Overlay presentation: dims the page behind the bar. |
.z-offcanvas-page | element | .z-drawer | Page root class clipping horizontal overflow while an offcanvas is open. |
.z-offcanvas-reveal | element | .z-drawer | Reveal presentation: the bar's wrapper grows in width instead of sliding. |
Accessibility
| Part | ARIA | Description |
|---|---|---|
content | — | Scrollable content region; no ARIA attributes. |
drawer | aria-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. |
handle | aria-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.