Popover
HkPopover is the library's general anchored surface: a panel pinned to a trigger, teleported out of the DOM flow, on either of the twelve placements, with a page dim behind it on desktop and a bottom-sheet form on phones. It owns the surface and nothing else — the content is the host's slot — so it is what every "open something next to this control" interaction is built from.
- Reach for it when content belongs to a trigger and should be dismissible: a filter panel from a header button, a details card from a row, a compact form from a toolbar verb. For a hover hint use Tooltip — a bubble that cannot hold controls; for a list of choices use SelectPanel or PopupSelect.
- This is the hinge of the group. PopupSelect mounts it for its list layer (the Rust mirror literally renders a nested Popover); Tooltip is its lightweight sibling on the same popup-manager bands; ContextMenuProvider and SelectPanel borrow the family's surface grammar (the .hk-select-popout* canvas and the inline position: fixed geometry) rather than this component. FloatingLayer and AmbientLayer are the two always-on bands, not anchored surfaces.
- The trigger is the host's: this component never renders a button, never toggles itself, and never decides when to open. modelValue / open is controlled on both sides.
Import
;
from "@celestia-island/hikari";
use *; // Popover, PopoverPlacement, PopoverSide, PopoverAlign,
// PopoverAnchorRect, popover_position_style,
// anchor_rect_from_element_id, popover_shields
use *; // PopoverProps, rsx!, VNode, EventHandler
The Rust form is Popover(PopoverProps { … }); the content is the children: Element field. Inside rsx! the panel content may be written directly as children of the component (that is the default slot's mirror), and every prop may be omitted — except open, which defaults to false, so a closed popover renders nothing at all. In the Rust default backdrop is true and placement is bottom.
The Rust default for open is false; the Vue one is a required prop. Vue makes modelValue required: true, so there is no "default state" to disagree about there — the divergence only bites a Rust host that forgets open: true. It also means every Rust example of this page passes open: true explicitly: an anchored panel is invisible to a snapshot otherwise, and even when open the panel is painted from inline geometry, not from an interactive runtime.
Placement, geometry and the sheet arm
The twelve placements are side × start | center | end; the bare sides (top, bottom, left, right) mean center. Vue measures the anchor element every time the panel opens or the viewport moves and then flips and clamps inside the viewport gutter. The Rust form takes a rect — PopoverAnchorRect { x, y, width, height }, measured by the host with platform::get_bounding_client_rect or anchor_rect_from_element_id("<id>") — and the pure popover_position_style(placement, anchor, offset) writes left / top (or bottom / right for the Top* / Left* sides) plus the alignment transform. Side offset defaults to 4px on both sides.
The sheet arm keys off sheet_on_mobile + the live viewport width (< 768px) in Rust and off useBreakpoint().isMobile in Vue. On the sheet arm the panel carries role="dialog", aria-modal="true", tabindex="-1", a grabber, a title band and a close button; the anchored arm has role="dialog" and nothing else modal about it.
padding takes the crate's shared inset enum — the same HkPad scale every container reads. It lives in hikari_components::utils, not in the prelude and not in the crate root, so the second Rust fence above carries its own use hikari_components::utils::HkPad; line: the engine's fence wrapper only imports the root glob and the prelude. Omit padding and you never need that line.
Both cards paint the same open panel with the same modifiers: div.hk-popover-panel.hk-popover-bottom-start.hii-dropdown-content with role="dialog" and aria-label="Details". The TSX card behaves like a real popover — press the trigger, click anywhere else, press Escape; the Rust card is a static statement of the open frame, with backdrop: false because it sits in a bordered stage and would otherwise dim the whole card.
Snapshot note. A Vue popover only mounts after its opening edge (machine.mounted), so it appears in a static snapshot only because open starts true there. The Rust mirror renders from the first paint whenever open: true — there is no animation machine to wait for, which is also why the Rust card cannot show a leaving transition.
[D] No auto-flip, no clamp in Rust. The mirror uses the placed side/align verbatim — it is Vue's autoFlip: false path — because flip and clamp need the panel's measured box, and the crate has no ref + measurement pairing. In practice: a Rust panel near a viewport edge may overflow; the host chooses a placement that fits.
Dismissal: the shield, the host, and what is not there
Vue installs a capture-phase document click listener while the panel is open; closeOnBackdrop gates it, and it applies whether or not the backdrop dims the page. It also spares the anchor (anchorRef.contains(target)) and — crucially — spares a higher popup layer so that picking an option inside a nested popout does not slam the parent's panel shut.
The Rust mirror keeps the same rule and reuses the crate's page-wide outside-click shield (overlay::outside_click): while the anchored branch is open, a click outside the layer host and outside anchor_selector asks the host to close through on_open_change(false). Pass the trigger's selector in anchor_selector — otherwise a click on the trigger closes the panel before the trigger's own toggle runs, and the toggle reopens it.
popover_shields(close_on_backdrop, sheet_branch) is the pure statement of the gate: the anchored branch only, and only when closeOnBackdrop allows it. The sheet branch dismisses through its scrim.
The two cards show the "the host owns dismissal" shape: on the TSX side by backdrop={false} (no page dim) — then click outside the open panel and watch it close, because a backdrop-less popover still dismisses on an outside click unless closeOnBackdrop says otherwise. The Rust card disables that path outright and additionally passes anchor_selector, the only way it can be told which element is the trigger. The Rust card never renders #details-trigger: a snapshot has no trigger to draw, and the selector is inert without a page to listen on (see the next note).
What a snapshot cannot show (Rust). outside_click::arm returns false on the server/native platform — there is no document to listen on — so the layer host simply carries no data-hk-outside attribute in a rendered snapshot. The behaviour exists in the browser build; the markup shown here is the honest static frame. Do not read the missing attribute as "the shield does not work".
Source defect (Rust). Popover's Escape handling has no defaultPrevented guard, unlike Vue's onPanelKeydown — Vue deliberately yields the key to a control inside the slot that already consumed it (the HkModal / HkDrawer precedence rule), and the Rust mirror closes unconditionally. A panel hosting its own Escape handling (a nested select, a typeahead) will close the popover and run the inner handler on the same press. Until this is fixed, avoid nesting Escape-owning controls one level inside a Rust Popover.
Source defect (Rust). Sheet-mode aria-modal="true" is emitted by the mirror exactly as Vue emits it, but nothing in the Rust mirror traps focus or moves it into the sheet (tabindex="-1" is printed, focus is never placed). A dialog-marked surface whose focus stays on the trigger is a contradiction an assistive-technology user will notice. The Vue form focuses the panel on open; the Rust host must do it.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | Boolean | — | ✓ |
| placement | String as PropType<PopupPlacement> | "bottom" | — |
| offset | Number | 4 | — |
| autoFlip | Boolean | true | — |
| backdrop | Boolean | true | — |
| closeOnBackdrop | Boolean | true | — |
| closeOnEscape | Boolean | true | — |
| glass | Boolean | true | — |
| padding | String as PropType<HkPad> | undefined | — |
| anchorRef | <code>Object as PropType<HTMLElement | null></code> | null | — |
| sheetOnMobile | Boolean | false | — |
| title | String | "" | — |
| aboveChrome | Boolean | false | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | boolean |
| registered | PopupHandle |
| closed | — |
| mouseenter | MouseEvent |
| mouseleave | MouseEvent |
Rust
Props — Popover
| Prop | Type | Default | Description |
|---|---|---|---|
| open | bool | false | Controlled open state (Vue: modelValue). |
| placement | PopoverPlacement | PopoverPlacement::Bottom | — |
| offset | f64 | 4.0 | Side gap in px (Vue default 4). |
| backdrop | bool | true | Dim/detach the page behind the anchored panel (Vue default true). |
| close_on_backdrop | bool | true | Backdrop / scrim click closes (Vue default true). |
| close_on_escape | bool | true | Escape closes (Vue default true). |
| glass | bool | true | Glass chrome (adds .hii-dropdown-content; Vue default true). |
| padding | Option<HkPad> | None | Panel content-inset override (--hk-pad; see utils::pad). |
| anchor | Option<PopoverAnchorRect> | None | The trigger rect to anchor against (see anchor_rect_from_element_id); without it the panel keeps the sheet's fixed default position. |
| anchor_selector | Option<String> | None | A CSS selector for the trigger this popover anchors against (Vue: anchorRef). |
| sheet_on_mobile | bool | false | Dock as a bottom sheet on mobile-width viewports (<768px), exactly like Vue's sheetOnMobile. |
| title | String | "" | i18n-resolved surface name (sheet heading + aria-label). |
| class | String | "" | — |
| children | Element | (empty) | — |
| on_open_change | Option<EventHandler<bool>> | None | Fires with the desired open state (Vue: update:modelValue). |
Accessibility
- The anchored panel is a role="dialog" with the title as aria-label (Vue passes title || undefined, Rust drops an empty title). It is non-modal: aria-modal and tabindex are only added on the sheet arm. Give it a title — an untitled popover has no accessible name at all.
- The sheet arm adds aria-modal="true" and takes focus (tabindex="-1"), a grabber that closes it, and a heading row with a ✕ button labelled by the localized "Close". On mobile the popover is a window layer; do not put a second dialog inside it. In Rust the focus half does not happen — see the source defect above.
- closeOnBackdrop governs an accidental dismissal gesture, not closability: Vue never consults it when the modal-stack breadcrumb dismisses the sheet, and the sheet always renders its own ✕. Do not repurpose it as a "modal" switch.
- Escape closes the panel unless a control inside it consumed the key first (Vue checks defaultPrevented). That precedence is what lets a nested select close alone.
- The popover suppresses native title tooltips on the anchor and its descendants while it is open (Vue), so a hover hint cannot fire on top of the open surface. Titles added to the subtree after opening are not suppressed — they are intended content.
- Rust: there is no focus management. The host must move focus into the panel on open, return it to the trigger on close, and close the panel on Escape when it hosts the surface inside a larger window.
- [D] Vue's mouseenter / mouseleave emits fire on the whole panel, so a host can implement hover-intent travel between trigger and panel without the open → leave → close → enter loop. The Rust mirror has no such pair.
Related components
- PopupSelect — the selector built on this layer.
- Tooltip — the hover-only sibling for text hints.
- SelectPanel — the dropdown surface that borrows the same canvas and geometry.
- FilterTrigger — a header affordance that hosts a panel in a popover.
- FloatingLayer — page chrome that outlives the window stack, instead of a trigger's panel.