AmbientLayer
HkAmbientLayer is the shared host for always-visible annotations that must paint above every popup — the modal backdrop included. It is the smallest component in this group and the strictest about its job: one viewport-spanning wrapper, a fixed document band, pointer events off by default, and everything visible is the host's slot.
- Reach for it when something must stay readable while windows are open: a screen-identify number over a board, a recording mark, a kiosk readout. That is annotation, not interaction.
- Do not reach for it for anything clickable by default, or for anything a window owns. Interactive chrome that must survive a dialog is FloatingLayer; a menu or an anchored panel is Popover or SelectPanel.
- The component exists because of a concrete defect (Vue, 2026-11-05): the screen-identify card was teleported to <body> with a hand-written z-index: 5000, so the modal tree buried it and the card showed through the scrim as dimmed background. Layer selection is a library decision — one HUD root, one band — not a per-consumer number.
Import
;
use *; // AmbientLayer, AmbientLayerPointerEvents, AMBIENT_LAYER_DOCUMENT_Z,
// ambient_layer_style, ambient_layer_landmark
use *; // AmbientLayerProps, VNode, Element, rsx!
The Rust form is AmbientLayer(AmbientLayerProps { … }). Its content is children: Element — the default slot — and, unlike the other layers in this group, pointer events are typed: pointer_events: AmbientLayerPointerEvents (None / Auto), which maps to the sheet's data-pointer-events token.
The band, stated as numbers
Both runtimes ship the same document band, and the Vue module documents it as a table (values from overlay/hudRoot.ts):
| z-index | Surface |
|---|---|
| 90000 | #hk-overlay-root — every popup, the modal backdrop included |
| 90050 | #hk-hud-root — the ambient HUD (this layer) |
| 95000 | error landing |
| 96000 | emergency-alert takeover |
| 100001 | the shell's window titlebar |
| 100002 | #hk-top-root — caption-band attachments |
The band is a custom property (--hk-z-hud, fallback 90050) so a themed scale sheet can move it without touching component code. AMBIENT_LAYER_DOCUMENT_Z is the Rust constant carrying the same fallback.
Vue teleports the layer into #hk-hud-root and gives the wrapper only the local order — style={{ zIndex: String(props.zIndex) }}, default 1 — because the root already sits on the document band. That is also why the HUD root exists at all: #hk-overlay-root is the fenced home of every interactive floating layer, and a HUD has no business in the popup manager's z arithmetic.
Both cards build the same two elements: div.hk-ambient-layer[data-pointer-events="none"][role="region"][aria-label="Screen 12"] with the annotation inside. What differs is where the band comes from. The TSX card writes a bare local order and relies on #hk-hud-root for the 90050 seat. The Rust card has no HUD root to teleport into, so the wrapper itself carries the arithmetic: z-index:calc(var(--hk-z-hud, 90050) + 0) for the default seat — i.e. band + z_index - 1, so z_index: 1 is the band floor and larger numbers stack nearer the user.
Rust gap — no HUD root. There is no <Teleport> and no #hk-hud-root: the layer renders in place, and the sheet's position: fixed plus the inline z-index calculation put it on the same document band the Vue HUD root occupies. Hosts must keep it out of transformed or contained ancestors — the same delta FloatingLayer and the Modal / Drawer mirrors document.
Pointer events: the opt-in targets children only
The wrapper spans the viewport. It is therefore a ghost: pointer-events: none by default, and pointerEvents="auto" restores pointer events on the slot children only. Re-enabling it on the wrapper itself would swallow every click behind an "interactive" HUD — the R2 S2 fix in the Vue library. Keep an interactive HUD's footprint small so it never covers what it annotates.
The TSX card is an annotation chip with a real verb — the one case the opt-in exists for. The Rust card says the same thing with the typed enum: data-pointer-events="auto" on the wrapper, whose own hit area stays transparent, with the button inside catching the press. z_index: 2 puts it one step above the first example's seat, which is the only ordering this component understands — it never compares against windows.
[D] The empty label is not symmetric with aria_label in the other layers. Vue binds aria-label={props.label} unconditionally and adds role="region" only when the label is non-empty, so label: "" and "no label" differ: an empty string still emits aria-label="". The Rust mirror reproduces that exactly — Option<String> = None drops both attributes, Some("") emits aria-label="" with no role — and ambient_layer_landmark(label) is the exported predicate that decides the role.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| pointerEvents | <code>String as PropType<"none" | "auto"></code> | "none" | — |
| zIndex | Number | 1 | — |
| label | String | undefined | — |
Rust
Props — AmbientLayer
| Prop | Type | Default | Description |
|---|---|---|---|
| pointer_events | AmbientLayerPointerEvents | AmbientLayerPointerEvents::None | Whether the layer's CONTENT accepts pointer input (default none). |
| z_index | i32 | 1 | Stacking order among ambient layers (Vue: zIndex, default 1). |
| label | Option<String> | None | Accessible name for the layer as a landmark (Vue: ariaLabel); an empty value drops role but still emits aria-label="" (Vue binds the attribute unconditionally). |
| children | Element | (empty) | The annotation widgets (Vue: the default slot). |
Accessibility
- label is the layer's landmark name: a non-empty value gives role="region" and aria-label. Name an annotation that carries information ("Screen 12", "Recording"); a purely decorative host should carry no label at all.
- Do not re-announce. The card inside usually carries its own status role (the screen-identify card is role="status" on both sides), and this wrapper adds a landmark around it; a second live region here produces a double announcement.
- With pointerEvents="auto" the interactive content is focusable, but the wrapper it sits in is still a viewport-sized ghost: keep the tab stop count inside the HUD at one or two, and never nest a container that assumes it owns the keyboard.
- An annotation that is always visible is also always in the accessibility tree. Anything long enough to read on demand belongs behind a popover, not here.
- [D] The Vue root is #hk-hud-root (pointer-events: none, isolation: isolate); the Rust mirror has no root and puts the band on the wrapper. Neither root is aria-hidden, deliberately: the Vue review of 2026-11-10 (#1206) removed a wholesale-hidden overlay root because it buried every popup from assistive technology. The rule that replaced it holds on both sides — decorative layers mark themselves aria-hidden, the shared roots never do.
Related components
- FloatingLayer — the other always-on band: chrome, pointer-transparent by construction, for page tools rather than annotations.
- Modal — the window whose backdrop this layer must out-paint.
- HkScreenIdentifyCard / ScreenIdentify — the status card whose 2026-11-05 defect this layer exists to prevent; it carries the role="status" announcement this wrapper deliberately does not add.
- Popover — for content that belongs to a trigger and can be dismissed.