SelectPanel
HkSelectPanel is the dropdown surface a select opens, detached from the select's trigger: give it an anchor and row content and it behaves exactly like the panel HkSelect would have opened — desktop popout on one side of the trigger, bottom sheet on phones, scrim, grabber, heading, and the rows.
- Reach for it when you want a dropdown's look and behaviour without being a <select>: filter popovers anchored to icon buttons, checkbox-list popovers, a picker with custom row markup. For a field-shaped control that already owns its trigger, use PopupSelect; for a menu of verbs, ContextMenuProvider borrows this canvas; for free-form panel content with no option model, Popover.
- It is the structure end of the chain: PopupSelect is the component that puts a trigger in front of a select-like list, and on the Vue side that one composes HkPopover, not this panel. What they share is the drop-in DOM grammar (hk-select-popout*, hk-select-sheet*, .hk-select-option) and the geometry helper — which is why a context menu, a select popout and a panel popover all land the same way against their anchor.
- Two content bands, and they matter: the default slot scrolls, the pinned header does not. Put a live-filter search field in pinnedHeader and it stays put while the catalog scrolls under it.
Import
;
from "@celestia-island/hikari";
use *; // SelectPanel, SelectPanelBranch, SelectPanelPlacement,
// select_panel_branch, select_panel_popout_style, select_panel_cap_style,
// select_panel_rows, select_panel_commit_row, select_panel_key_action,
// select_panel_outside_click_closes, SelectOption, SelectAnchorRect,
// select_popout_style, step_highlight
use *; // SelectPanelProps, rsx!, VNode, Element, EventHandler
The Rust form is SelectPanel(SelectPanelProps { … }). Two prop names differ from Vue's: the anchor is a rect (SelectAnchorRect, the same shape as PopoverAnchorRect), and Vue's pinnedHeader slot is pinned_header: Option<Element>. The rows are a typed model (Vec<SelectOption>) rather than arbitrary markup.
Placement, width parity and the cap
placement is bottom-start (both defaults), bottom-center, bottom-end, top-start, top-center, top-end. offset is the gap to the anchor (4px on both sides) and matchAnchorWidth ties the popout's minimum width to the trigger, which is the select parity every dropdown needs.
maxHeight caps the desktop popout and nothing else: it is published as --hk-select-panel-max-height on .hk-select-popout, and the mobile sheet deliberately ignores it (a sheet hugs its content up to the family ceiling of 80% of the viewport). A malformed value is not sanitized — it becomes invalid at computed-value time and resolves to max-height: none, i.e. uncapped.
Both cards show the open popout below a trigger: div.hk-select-popout-host[data-side="bottom"][data-align="start"] wrapping div.hk-select-popout[aria-label="Mailbox"], the cap on the inner panel. Vue's rows are whatever the slot renders; the Rust rows are generated from options with the four data-* markers. The TSX card is a working panel — press the trigger, click a row area, press Escape or click outside; the Rust card paints the given frame, with active_branch pinned to Popout so a server render (which reports a desktop width) can never drift into the sheet arm.
What a snapshot cannot show (Rust). The popout is rendered with inline position: fixed geometry from SelectAnchorRect, and the mirror does not teleport it; it therefore paints inside whatever box its host wrote. That is why every example on this page passes an explicit anchor and keeps the panel inside a bounded wrapper. The data-hk-outside shield attribute is absent in a static render — outside_click::arm reports "no page to listen on" outside a browser — and its absence here is not a behaviour gap.
The two form factors, and the pinned band
sheetOnMobile (default true on both sides) docks the panel as a bottom sheet below 768px: scrim (click closes), role="dialog" + aria-modal="true" panel, grabber, a heading row with a ✕, then the list. Above the breakpoint it is the anchored popout. Vue decides once, on the opening edge, and remembers the born form factor (activeBranch) so a viewport crossing mid-flight closes in the shape it was born in; the Rust mirror takes that as the controlled active_branch prop, or re-decides from the live viewport on every render.
pinned_header / the pinnedHeader slot is a structural decision, not a style one: with it, the popout grows an is-pinned-header modifier, a .hk-select-popout-pinned head and a .hk-select-popout-body-host → .hk-select-popout-body scroll region (the sheet gets .hk-select-sheet-pinned between the title row and the body). Without it, the popout keeps the pre-slot DOM byte for byte and scrolls as one box.
Both cards carry the band: the TSX card through the pinnedHeader slot (a slot's presence is what hasPinnedHeader() reads every render), the Rust card through pinned_header: Some(...). The resulting column is the same — pinned head, body host, body, rows — and the rows are the same .hk-select-option markers. max_height still lands on the panel, because with a pinned header the panel is the closed flex column that bounds the body.
Rust gap — no transition, no size morph, no overlay scrollbar. The crate ships no enter/leave transitions (hk-select-popout-* / hk-select-sheet-* are Vue <Transition> names), no surface machine, no back guard, no scrollIntoView, and no overlay scrollbar. It renders the same boxes and leaves the native bar to the sheet, which hides it on the body exactly as it does on the panel. The pinned band changes where a scrollbar would go, not that there is one.
Keys, the outside click, and the split of state
Vue keeps open's writer in the parent and highlightedIndex / activeBranch in local refs; the panel forwards keydown from its surface so an owner with an option model (like HkSelect) can run its own arrow/Enter navigation. The Rust mirror stores nothing: open, highlighted_index and active_branch are all props with on_open_change / on_highlight_change / on_value_change writers, and the key grammar is the pure select_panel_key_action(key): arrows step the cursor with wrap-around, Enter commits the highlighted row unless it is disabled, Escape closes and consumes the key exactly once so a dialog hosting the panel does not close on the same press.
The outside click is the crate's page-wide shield on the popout branch only (the sheet dismisses through its scrim). It needs the trigger's selector in anchor_selector — otherwise a click on the trigger closes the panel before the trigger's own toggle runs. select_panel_outside_click_closes(open, sheet_branch, in_anchor, in_panel_host) is the exported predicate a host can ask directly.
The upward placement is the point: a control near the bottom of a page opens its panel above the trigger, and both cards say so with top-start (the Rust geometry writes bottom instead of top, so no panel height is needed). The Rust card adds anchor_selector because a rect cannot answer "did the press land on the trigger?" — and sheet_on_mobile: false pins the popout on the Rust side, which is what the TSX card gets for free by never leaving the desktop breakpoint in a preview.
[D] No auto-flip, no clamp. Both features need the measured panel box (offsetWidth / offsetHeight, the popup viewport, the gutter clamp) and the crate has no ref + measurement pairing. The Rust mirror uses the placed side/align verbatim — exactly Vue's autoFlip: false path — so data-side / data-align carry the placed orientation where Vue writes the resolved one.
[D] No breakpoint auto-close. Vue closes an open panel when the viewport crosses 768px. The Rust branch is re-decided per render (or pinned by active_branch); the host re-evaluates on resize through the exported select_panel_branch(sheet_on_mobile, viewport_width).
Source defect (Rust). SelectPanelProps::open is documented "Vue: open, required — CONTROLLED (the parent owns the flag)" but carries no #[default] — the generated API table above shows a false in the Default column only because the tool falls back to the type's own default. A Rust call site therefore does have to spell open:, and ..Default::default() quietly yields open: false. Nothing breaks; the risk is a host that builds props with ..Default::default() and silently renders nothing, because a closed panel produces an empty vnode by design ("a closed panel mounts no surface"). Pass open: true (or the host's real flag) explicitly.
Source defect (Rust). The sheet arm's ✕ glyph is drawn at IconButtonSize::glyph_px (20px at size 32) rather than Vue's literal 16, a row-level divergence the IconButton mirror documents for every caller. It is cosmetic, but it means the sheet's close button is visibly larger on the Rust side than on the Vue side.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| open | Boolean | — | ✓ |
| anchorRef | <code>Object as PropType<PanelAnchor | null></code> | null | — |
| title | String | "" | — |
| placement | String as PropType<SelectPanelPlacement> | "bottom-start" | — |
| autoFlip | Boolean | true | — |
| offset | Number | 4 | — |
| matchAnchorWidth | Boolean | true | — |
| maxHeight | String | undefined | — |
| sheetOnMobile | Boolean | true | — |
| aboveChrome | Boolean | false | — |
Emits
| Event | Payload |
|---|---|
| update:open | boolean |
| keydown | KeyboardEvent |
Rust
Props — SelectPanel
| Prop | Type | Default | Description |
|---|---|---|---|
| open | bool | false | Vue: open, required — CONTROLLED (the parent owns the flag). |
| options | Vec<SelectOption> | [] | The rows the surface carries. |
| model_value | String | "" | The row that reads as selected (data-checked). |
| highlighted_index | i32 | -1 | Keyboard/pointer highlight; -1 means "none" (Vue: the local highlightedIndex ref). |
| title | String | "" | Sheet heading and the popout's aria-label (Vue: title, published as <code>title || undefined</code>). |
| placement | SelectPanelPlacement | SelectPanelPlacement::BottomStart | Desktop-popout placement (Vue default "bottom-start"). |
| offset | f64 | 4.0 | Gap between the trigger and the popout, in px (Vue default 4). |
| match_anchor_width | bool | true | Tie the popout's minimum width to the trigger (Vue default true). |
| max_height | Option<String> | None | Cap for the DESKTOP POPOUT, as any CSS length (Vue: maxHeight). |
| pinned_header | Option<Element> | None | Vue's pinnedHeader SLOT: chrome that must stay reachable while the content scrolls — a live-filter search field above a long catalog, first of all. |
| sheet_on_mobile | bool | true | Dock as a bottom sheet on phone-width viewports (Vue default true). |
| active_branch | Option<SelectPanelBranch> | None | The form factor the surface opened in (Vue's local activeBranch ref, promoted like the other refs). |
| anchor | Option<SelectAnchorRect> | None | The trigger rect to anchor against (feedback::popover:: anchor_rect_from_element_id measures one by id). |
| anchor_selector | Option<String> | None | A CSS selector for the trigger the host anchors against (Vue: anchorRef). |
| class | String | "" | Extra class on the surface root (the popout host / the sheet panel). |
| on_open_change | Option<EventHandler<bool>> | None | Fires with the desired open state (Vue: update:open). |
| on_value_change | Option<EventHandler<String>> | None | Fires with the chosen row's value. |
| on_highlight_change | Option<EventHandler<i32>> | None | Fires with the desired highlight index. |
Accessibility
- Name the surface with title: it becomes the popout's aria-label, and on the sheet it is both the heading and the accessible name. An untitled panel is an unnamed layer.
- The sheet arm is a real dialog: role="dialog", aria-modal="true", tabindex="-1", a grabber and a ✕ labelled by the localized "Close". The popout arm has no role of its own — the rows are expected to carry the semantics. Vue forwards keydown to the owner so its option model supplies aria-selected / listbox roles; the Rust mirror renders div.hk-select-option markers and leaves the roles to the host's own wrapper.
- Escape closes one layer and consumes the key (select_panel_key_action → CloseAndConsume), so a dialog hosting the panel keeps its own Escape. Arrows wrap; Enter commits only a committable row; every other key is forwarded.
- The panel must hold focus for its keys to arrive, and Vue's sheet focuses itself on open. The Rust mirror does not — the host moves focus in and returns it on close.
- Rows mark state with presence-only attributes: data-highlighted, data-checked, data-disabled are either present (="true") or absent, never ="false", because a serialized "false" would still match a [data-*] selector. Read them as booleans, not as strings.
- Put the search field in pinnedHeader, not in the scrolling content: the first swipe would otherwise scroll the filter (and its focus ring) off the sheet.
- [D] Vue runs a duplicate-title filter on the mobile sheet (.hk-sheet-dup-title hides content that opens by repeating the panel title). The Rust mirror renders rows only and never scans; the class remains a hook for hosts that slot their own markup.
Related components
- PopupSelect — the trigger-plus-list control built beside this panel.
- Popover — the generic anchored surface, when the content has no option model.
- ContextMenuProvider — the pointer-anchored menu on this canvas.
- Select — the canonical field this surface was extracted from.