GhostHoverCard
GhostHoverCard shows a rich preview on pointer hover or keyboard focus of a trigger, with open and close delays so users can move onto interactive content. Import GhostHoverCard, GhostHoverCardTrigger, and GhostHoverCardContent from @ghostvue/vue for headless use, or from @ghostvue/themes for the default elevation surface.
Elevation-3 surface tokens for rich preview cards.
Hover over or focus the @ghostvue/themes button to preview the package. The delay lets the pointer move from the trigger into the card, and the card stays open while focus is inside. Press Escape to dismiss it. Put essential information on the page so it remains available without opening the preview.
Advanced: headless composition
Basic use
Unstyled hover/focus preview card with delays, interactive content, and Escape dismissal.
Use the headless parts when your application supplies the preview surface and focus styling. The same delay, positioning, and dismissal behavior applies.
API
See the generated component references for props, emits, slots, exposed members, styling hooks, CSS variables, and executable examples.
| Prop | Type | Default | Description |
|---|---|---|---|
closeDelay | number | 300 | Milliseconds before hiding after hover/focus leaves the trigger and content. |
closeOnEscape | boolean | true | When true, Escape dismisses the open card via useDismissableLayer. |
defaultOpen | boolean | false | Initial open state when open is omitted. |
open | boolean | — | Controlled open state. Omit for uncontrolled mode. |
openDelay | number | 700 | Milliseconds before showing after hover or focus begins. |
| Slot | Slot props | Description |
|---|---|---|
default | close: () => void, open: boolean | Primary content. |
@ghostvue/themes adds no props, events, or slots to the headless GhostHoverCard API, which it forwards.
GhostHoverCard (root)
Supports openDelay, closeDelay, and closeOnEscape. Emits update:open with (open: boolean). The default slot receives { open: boolean, close: () => void }.
GhostHoverCardTrigger
Sets type="button" (when as="button"), aria-haspopup="dialog", aria-expanded, and aria-controls, data-part="trigger", and data-state="open" | "closed". Schedules show on pointerenter / focusin and hide on pointerleave / focusout when not disabled. Exposes { element, focus, blur }.
GhostHoverCardContent
Keeps visibility: hidden until useFloating().isPositioned resolves. Sets role="dialog", tabindex="-1", data-part="content", data-hoverable, data-state="open", and data-placement. Interactive descendants are allowed. Exposes { element, focus, blur }.
Accessibility
- Preview semantics: The trigger exposes
aria-expandedand names the associated dialog surface viaaria-controls/aria-labelledby. - WCAG 1.4.13:
closeDelaypreserves a grace period before hiding; pointer movement onto the card keeps it open while the trigger stays focused. - Dismissal:
Escapeand outside pointerdown close the card without trapping focus. Tab moves through focusable content inside the card.
Specification
See GhostHoverCard specification and ADR 0011.