Drawer
HkDrawer is the docked window: a panel that slides in from one of the four edges over a dimmed, blurred backdrop. It carries the same window grammar as HkModal — a title bar with a ✕, a scrolling body, an optional footer band, focus trapping, Escape and overlay dismissal, a back-gesture history entry — but its geometry comes from the edge it docks to rather than from a centred frame.
- Reach for it when the surface is a side rail (navigation, filters, a detail pane beside the list) or a deliberate sheet that should not feel like a modal — a settings pane, a comment thread, a filter set.
- Reach for Modal when the task should feel like an interruption, and for AdaptiveDialog when the bottom sheet is the phone answer to a centred dialog rather than the intended shape at every width.
- side="bottom" is the phone sheet form of the family: it docks on the shared sheet gap, caps to the family's viewport formula and stacks the home-bar safe area into its footer. The side docks (left / right) keep their desktop geometry on phones.
Import
;
use *; // Drawer, DrawerSide, drawer_panel_style, drawer_panel_classes
use *; // DrawerProps, rsx!, VNode, Element, EventHandler, KeyboardEvent, MouseEvent
use HkPad; // the named padding step the `padding` prop takes
The Rust form is a plain function, Drawer(DrawerProps { … }). Inside rsx! every prop may be omitted, and a closed drawer renders nothing. HkPad is the one prop type outside the crate glob — it lives in hikari_components::utils, not the prelude.
Sides, sizes and the overlay
side takes left / right (the default) / top / bottom. size is the panel's docked-axis length: on the vertical sides it becomes width with max-width: 85vw, on the horizontal ones height with max-height: 70vh. So size="480px" means a 480px-wide rail on right and a 480px-tall band on top, clamped to the 70vh cap. CSS length strings are the contract — the retired legacy drawer's named small / medium / large presets are gone.
overlay draws the dim backdrop and also feeds aria-modal; turning it off leaves the panel alone on the page, which is the right shape for a persistent rail but the wrong one for anything modal. A press on the overlay dismisses when closable and overlay are both on. Vue has no separate flag for that gate; the Rust form adds mask_closable on top (default true, so the default behaviour matches Vue) and a press needs closable && overlay && mask_closable.
padding retunes the body through the shared --hk-pad token (none / xs / sm / md / lg); unset keeps the sheet's 1rem body padding. A Rust host writes Some(HkPad::Sm) and imports the type from hikari_components::utils; the fence below leaves the prop out so it stays inside the prelude. panelClass is the escape hatch for the teleported panel — attrs fall through to a component root, not to a panel inside the overlay root — and it is appended after the side modifier, which is how hosts scope body and footer padding overrides.
Both cards are the same open panel painted statically: hk-drawer-panel hk-drawer-left, 288px wide, capped at 85vw. drawer_panel_style(side, size) and drawer_panel_classes(side, panel_class) on the Rust side are the pure twins of Vue's panelStyle and class list, if a host wants to reason about the geometry without rendering.
The header, the body and the footer band
The header renders when title or the header slot is present. The slot replaces the title span rather than joining it — that is why AdaptiveDialog composes its own title + slot block for the phone shell. The ✕ sits at the inline end of that band each time closable is true; with closable: false the band has no dismissal, and Escape and the overlay no longer close the drawer either.
The body is the scroller (.hk-drawer-body-wrap positions it, .hk-drawer-body is the scroll region), and the footer band exists only when the footer slot is passed — there is no footerActions prop here, so a caller that wants an action row writes it into the slot.
[D] Visible differences in the Rust form:
- No motion; the transition class stays on. Vue's surface machine applies a -from then a -to pair for one transition and leaves the open panel with no extra class. The mirror has no transition driver, so the open panel carries its -enter-active class for its whole lifetime and the overlay carries its own. Nothing animates in (without the -from frame there is no start state to interpolate from) and nothing animates out (closing removes the panel immediately — no leave class is emitted at all). One visible side effect: the -enter-active rule (transform only) replaces the width / height transition declared on .hk-drawer-panel, so a host that animates a size change loses that morph while the panel is open. That is a fidelity loss, not a feature — the mirror never morphs sizes itself.
- No z-band. Vue writes the overlay and panel z-index from the popup manager (panel = overlay + 1). The mirror writes none: DOM order — overlay, then panel — plus the host's stacking context decide. A host that needs a band scopes it through panel_class or its own tokens.
- No <Teleport>. Like the Modal mirror, the drawer renders in place; the sheet already makes both layers position: fixed.
The four docks, and what each one is for
bottom is the only dock whose phone geometry differs from its desktop geometry: at or below 767px it stops being a plain fixed band and joins the sheet family — it docks on the shared --hk-sheet-bottom-gap hook, caps to the family formula (100vh/100dvh minus the top inset) with !important so the inline max-height from size loses, takes the 12px family corner, and stacks the home-bar safe area into its footer padding. The side docks keep their own geometry at every width, including their footer contract.
top is the drop-down band (a toolbar, a notice strip) and shares the horizontal geometry rules with bottom, without the sheet-family phone treatment. left / right are the rails: the panel rounded on its inner edge only, a border on the inner edge, and the same 85vw cap.
Interaction
The interactive card keeps modelValue in a ref: the ✕, the overlay press and Escape all emit false, and the host writes it back. Vue also pushes a backGuard history entry on open (default on, gated on closable) so the system back gesture closes the drawer instead of navigating the page, and restores focus to the opener after the leave. The Rust form has neither — its on_close is the single dismissal channel and the snapshot never runs it. On a touch device a left or right drawer also follows a horizontal drag: dragging past 35% of the panel width — or a fast flick — dismisses it, and a shorter drag snaps back.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | Boolean | — | ✓ |
| side | String as PropType<DrawerSide> | "right" | — |
| title | String | undefined | — |
| closable | Boolean | true | — |
| overlay | Boolean | true | — |
| size | String | "320px" | — |
| headerless | Boolean | false | — |
| padding | String as PropType<HkPad> | undefined | — |
| panelClass | String | undefined | — |
| backGuard | Boolean | true | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | boolean |
| afterLeave | — |
Rust
Props — Drawer
| Prop | Type | Default | Description |
|---|---|---|---|
| open | bool | false | Controlled open state (Vue: modelValue). |
| side | DrawerSide | DrawerSide::Right | The edge the panel docks to (Vue: side). |
| title | Option<String> | None | Header title (span.hk-drawer-title); the header slot wins when set. |
| closable | bool | true | Render the ✕ and allow Escape to close (Vue default true). |
| overlay | bool | true | Render the dim overlay (Vue default true). |
| mask_closable | bool | true | Let an overlay click dismiss the drawer (needs closable too; see the header note — Vue derives this from closable, the default keeps Vue's behaviour). |
| size | String | "320px".to_string() | Docked-axis length: width on the vertical sides, height on the horizontal ones (Vue's size, default "320px"). |
| headerless | bool | false | Suppress the visible header ROW — no title span, no ✕ — even when title is set (Vue's headerless). |
| padding | Option<HkPad> | None | Body container-padding override (--hk-pad; see utils::pad). |
| panel_class | String | "" | Extra classes for the panel (Vue: panelClass). |
| header | Option<Element> | None | Header slot content; replaces the title span when provided. |
| footer | Option<Element> | None | Footer slot content (rendered inside .hk-drawer-footer). |
| children | Element | (empty) | Body content (Vue: the default slot). |
| on_close | Option<EventHandler<MouseEvent>> | None | Fired when the user asks to close (✕ / overlay click / Escape). |
Accessibility
- The panel is the dialog: role="dialog", aria-modal bound to overlay (so a panel with the backdrop off is announced as non-modal), aria-label from title, and tabindex="-1" so it can take focus. Vue drops the aria-label attribute entirely when there is no title, so an untitled drawer is unnamed — and a drawer whose heading comes from the header slot has to name itself another way (aria-labelledby on your own content, or a title).
- Vue traps Tab inside the panel, focuses the first focusable element when the open phase lands and returns focus to the opener after the leave; the ✕ is a real button named by the i18n key hikari::drawer.close ("Close"). Escape closes only while closable, and it yields to a nested control that already consumed the key.
- The overlay is a pointer-dismissal surface with no role and no tab stop; the keyboard path to the same outcome is Escape. The overlay press is gated on closable (and on overlay), so a non-closable rail cannot be dismissed by a stray tap.
- On a phone the bottom dock is a sheet, not a full-screen page: it stays capped under the top inset so the window-stack chrome above it remains visible, and its footer keeps the home-bar safe area clear.
- [D] The Rust panel writes aria-label unconditionally — aria-label="" when the drawer has no title — because rsx attributes cannot be omitted conditionally. You cannot reach the attribute from the host to add one; label a header-slot-only drawer from inside its content. Assistive technology ignores an empty label, so the practical result is an unnamed dialog rather than a mislabelled one.
- The Rust panel ships no Tab trap and no focus restore, and Escape only reaches it while focus is inside the panel — a Rust-only page must move focus into the drawer after opening it (the panel is focusable through tabindex="-1").
- On touch devices a left or right panel is also a drag-to-dismiss surface (35% of the width, or a fast flick). Like the overlay it is pointer-only: the keyboard path to dismiss stays Escape, and the gesture is gated on closable.
Related components
- Modal — the centred frame with the same window grammar.
- AdaptiveDialog — a dialog that uses this drawer's bottom dock as its phone shell.
- ConfirmDialog — a compact confirmation when the decision is a two-button choice.
- ProgressDialog — a non-closable progress window.
- MenuPanel — the row container that usually fills a rail's body.