Skip to content

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.

Themed

Elevation-3 surface tokens for rich preview cards.

Publishedwith updated elevation and portal token inheritance.

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 ​

Basic Headless

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.

PropTypeDefaultDescription
closeDelaynumber300Milliseconds before hiding after hover/focus leaves the trigger and content.
closeOnEscapebooleantrueWhen true, Escape dismisses the open card via useDismissableLayer.
defaultOpenbooleanfalseInitial open state when open is omitted.
openboolean—Controlled open state. Omit for uncontrolled mode.
openDelaynumber700Milliseconds before showing after hover or focus begins.
SlotSlot propsDescription
defaultclose: () => void, open: booleanPrimary 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-expanded and names the associated dialog surface via aria-controls / aria-labelledby.
  • WCAG 1.4.13: closeDelay preserves a grace period before hiding; pointer movement onto the card keeps it open while the trigger stays focused.
  • Dismissal: Escape and outside pointerdown close the card without trapping focus. Tab moves through focusable content inside the card.

Specification ​

See GhostHoverCard specification and ADR 0011.