Rendered by GPUI’s web backend from the real component. Requires a browser with WebGPU.
HoverCard supplies a rich, noninteractive preview of a Button's ordinary action.
Retain a stable trigger focus handle and create
HoverCardState::new(&trigger_focus, window, cx). Observe the state to redraw the
consumer. Optional .with_delays(open_duration, close_duration) configures pointer
entry and exit delays before mounting; defaults are 500 ms and 200 ms.
HoverCard::new("preset-preview", &preview)
.accessibility_label("Recording preset preview")
.offset(px(6.))
.trigger(|button| {
button
.accessibility_label("Recording preset. Edit settings")
.on_click(open_settings)
.child("Preset: Balanced")
})
.content(preview_surface)The trigger builder preserves the Button's action and supplies its appearance.
The state owns its focus handle and disabled state; use set_disabled to
coordinate the preview and Button. Styled methods on HoverCard apply to the
host frame. Style the application-supplied content separately, and use
.anchor(...) and .offset(...) for the existing Popup geometry.
| Input | Behavior |
|---|---|
| Pointer enters the trigger | Open after the entry delay without moving focus |
| Pointer leaves trigger and card | Close after the exit delay, unless the trigger retains keyboard focus |
| Pointer enters the card or returns to the trigger | Cancel delayed closing |
| Keyboard focus enters the trigger | Open immediately; focus remains on the Button |
| Escape | Dismiss a visible preview and suppress reopening during the current entry |
| Click / Enter / Space | Dismiss the preview; the Button or clicked control still performs its ordinary action |
| Focus changes / window deactivates | Dismiss without moving focus |
The close delay lets a pointer cross the trigger-to-card gap. Keyboard-opened previews remain until blur or explicit dismissal, even if the pointer moves away. Escape leaves focus in place and does not reopen the card merely because another frame is drawn or the pointer moves within the same trigger. A fresh trigger entry or keyboard focus can show it again. Cancelling a pending, undisplayed preview leaves Escape available to an enclosing surface.
State methods are is_open, is_disabled, focus_handle,
close(window, cx), and set_disabled(disabled, window, cx). Explicit close
suppresses the current entry. Re-enabling waits for another entry or focus.
Unmounting cancels delayed work and clears retained visibility; a mounted
Escape subscription belongs only to that window.
Popup owns placement, viewport clamping, deferred painting, and occlusion. The
visible preview is a supplementary Tooltip surface with no Tab stop; it never
opens a focus trap. accessibility_label names that surface. Keep essential
information available in the Button's accessible description or its ordinary
destination, rather than only in a pointer preview. Interactive content belongs
in Popover. Touch has no hover: a long press on the trigger opens the preview at
once without activating the Button, and the next press anywhere dismisses it. A
global hover provider is not supplied.
The example previews the current recording preset, recording date, and notes status. Clicking or pressing Enter on that same Button opens the settings Dialog, which returns focus to the Button when closed.