FloatingLayer
HkFloatingLayer is viewport-fixed chrome that outlives the window stack: a corner of the screen (a quick-action pad, a detached date dial) that stays reachable when a modal or a drawer opens over the page. It owns no interaction of its own — it is a positioned, pointer-transparent band — and everything inside it is the host's slot.
- Reach for it for chrome that belongs to the page, not to a window: the shell's quick-action pad, a modal's detached dial, anything that must survive "someone opened a dialog". A dialog's own footer actions belong in the dialog; an icon button in a toolbar is IconButton.
- It is the bottom of this wave's stack: Popover and Tooltip are anchored surfaces that need a trigger, whereas this layer needs nothing but a corner. Neither of them is built on top of it — the shared vocabulary is the band idea (see the section below), not inheritance.
- On the Vue side Fab consumes it directly: layer="top" wraps the button in an HkFloatingLayer and hands the corner/offset props over. The Rust Fab has no such variant yet.
Import
;
use *; // FloatingLayer, FloatingCorner, FloatingLayerEdges,
// floating_layer_geometry, floating_layer_visible, floating_layer_style
use *; // FloatingLayerProps, VNode, Element, rsx!
The Rust form is FloatingLayer(FloatingLayerProps { … }). Its content is the children: Element field — the default slot's mirror. Inside rsx! every prop may be omitted: open defaults to true (this surface is chrome, shown unless the host hides it), corner to bottom-right, the two offsets and z_index to "not written", and aria_label to "".
Geometry: the sheet owns the corner math
The corner is one data-corner attribute on div.hk-floating-layer, plus the optional --hk-float-offset-x / --hk-float-offset-y custom properties. The insets themselves (max(var(--space-14), env(safe-area-inset-*)) plus the host offset) live in the stylesheet — both runtimes compile the same vendored HkFloatingLayer.scss, so a corner resolves identically. The Rust helper floating_layer_geometry(corner) states that contract without re-deriving it: which viewport edge each axis pins to, and which safe-area variable its inset maxes against.
The layer itself is gesture-transparent (pointer-events: none on the sheet); the widgets inside catch their own pointers. The sheet's > .hk-fab { position: static } rule means a floated fab hands its viewport anchoring to this layer, which is exactly what HkFab layer="top" relies on.
Both cards declare the same layer; where it lands differs by construction. The TSX card teleports it to <body> and pins it to the live viewport, so it escapes the dashed stage entirely. The Rust card keeps the exact DOM contract — div.hk-floating-layer[data-corner="bottom-right"] carrying role="group" and aria-label="Page tools", with --hk-float-offset-x:12px;--hk-float-offset-y:12px inline — but renders in place, so the dashed stage's own box is what clips it in the snapshot.
Rust gap — no Teleport. Vue teleports to document.body, so no transformed or contained ancestor can re-anchor or clip the fixed layer. The Rust form has no Teleport seam: it renders where it is written and lets the sheet's position: fixed do the lifting. Keep it out of transformed ancestors (the same delta the Modal and Drawer mirrors document).
The band: z, yielding, and the four corners
In Vue the layer's z-index comes from the live popup manager: it registers as kind "tooltip" — non-blocking, untitled, no scroll lock, no outside-dismiss channel — so the band is derived from the registry instead of a magic constant, and two layers at one corner stack by open order. Inside that band, a tooltip registered later paints above this chrome; the library does not "fix" that with a magic z, and the code says so.
The Rust form has no manager. Three consequences, each an intentional difference:
- z_index is the band override. Unset keeps the sheet fallback var(--hk-overlay-z-popup, 200); set, it is written as --hk-float-z.
- yield_to_windows reads a host-owned flag: Vue asks the manager hasLiveWindow, the mirror takes windows_open from the host and gates through the pure floating_layer_visible(open, yield_to_windows, windows_open) — open && !(yield && windows_open).
- A hidden or yielded layer renders nothing at all (empty_vnode()), exactly Vue's return null.
The two cards are the same two corners. The Rust card passes z_index: Some(1200) because a host without a popup manager is the one that decides the band; the TSX card leaves it to the registry. Only the Vue runtime knows whether a window is open, so yieldToWindows cannot be shown in either static card: the TSX card starts visible and yields the moment a modal opens; the Rust card would pass yield_to_windows: true, windows_open: true to paint nothing — a state a snapshot cannot make meaningful, which is why it is not one of the examples.
[D] Vue registers the layer with the popup manager under kind "tooltip", i.e. the same band a hover bubble takes. It also puts the layer into readHkRuntime("popupManager"). The Rust mirror registers nowhere — the host owns the band (z_index) and any debugging list must enumerate the layer itself.
Source note (Rust). FloatingLayerProps::children is a required field with no default, so every Rust call site must spell children: (the two examples above do). Nothing is hidden by that — Popover and Tooltip declare theirs the same way.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| open | Boolean | true | — |
| corner | String as PropType<FloatCorner> | "bottom-right" | — |
| offsetX | String | undefined | — |
| offsetY | String | undefined | — |
| ariaLabel | String | "" | — |
| yieldToWindows | Boolean | false | — |
Rust
Props — FloatingLayer
| Prop | Type | Default | Description |
|---|---|---|---|
| open | bool | true | Controlled open state (Vue: open, default TRUE — this surface is chrome that is shown unless the host hides it). |
| corner | FloatingCorner | FloatingCorner::BottomRight | — |
| offset_x | Option<String> | None | --hk-float-offset-x (Vue: offsetX, any CSS length; unset = 0). |
| offset_y | Option<String> | None | --hk-float-offset-y (Vue: offsetY, any CSS length; unset = 0). |
| aria_label | String | "" | Accessible group name for the chrome (Vue: ariaLabel); empty drops both role and aria-label, like Vue's undefined. |
| yield_to_windows | bool | false | Yield the screen while any window is open (Vue: yieldToWindows). |
| windows_open | bool | false | HOST-OWNED "a window / dialog is open" flag (Vue: the popup manager's live window registry, which this release does not have). |
| z_index | Option<i32> | None | --hk-float-z band override (Vue: the manager's tooltip band; unset keeps the sheet fallback var(--hk-overlay-z-popup, 200)). |
| children | Element | (empty) | The chrome widgets (Vue: the default slot). |
Accessibility
- ariaLabel is the layer's whole accessible identity: a non-empty value emits role="group" and aria-label on the wrapping div; an empty value (the default) emits neither. Always name a layer that holds more than one control; a purely decorative layer should stay unnamed.
- The wrapper is pointer-events: none, so it never intercepts a click aimed at the page behind it. That also means a widget inside it is reachable only through its own hit area — do not rely on the lane around it.
- While a modal is open, this chrome stays pointer-reachable but not keyboard-reachable (Vue): the modal's focus trap owns Tab. That is the standing tradeoff of floating chrome, and a focus relay is explicitly out of scope in the Vue source. If the page needs the dial to be operable under a modal, the modal — not the layer — has to expose it. The Rust layer has no focus management at all, so its host owns tab order either way.
- When yieldToWindows is on, a layer that disappears while a window is open takes its controls out of the tab order with it. Any action that becomes unreachable that way must also be reachable from inside the window — say so in the window's own UI, not in the layer.
- [D] Vue registers the layer with the popup manager as a tooltip-band entry, which also puts it into readHkRuntime("popupManager"). The Rust mirror registers nowhere; a host that lists open surfaces for debugging must list this one itself.
- [D] The Vue layer keeps its band slot while yielded and releases it only on open: false; hasLiveWindow is consulted at render. The Rust mirror has no slot to keep — floating_layer_visible(open, yield_to_windows, windows_open) is a pure predicate the host can call anywhere, including outside the component, to ask the same question.
Related components
- Fab — the button that consumes this layer through layer="top" on the Vue side.
- Modal — the window this layer is designed to outlive.
- Drawer — the same problem on a side edge; it does not float above the stack.
- Popover — an anchored surface, for content that belongs to a trigger rather than to the page.