Hover Preview Card
HoverPreviewCard opens rich hover/focus content after a delay. Use it for link previews, user cards, repository cards, or entity summaries. If the content needs click-to-open behavior, use Popover instead.
Preview content has no role by default. Add ariaLabel only when content includes interactive controls and needs dialog semantics.
Anatomy
#trigger: Element that opens the card on hover/focus. UsetriggerPropson custom interactive triggers.#content: Rich preview content.
The root, trigger wrapper, floating content, and optional arrow are generated by the component.
Usage
Hover Ada Lovelace to open a preview card.
Examples
Custom delay
Use openDelay and closeDelay to tune hover behavior.
<template>
<HoverPreviewCard :open-delay="300" :close-delay="100">
<template #trigger>Hover me</template>
<template #content>Preview</template>
</HoverPreviewCard>
</template>
Controlled open state
Bind v-model when another interaction should own the card state.
<template>
<HoverPreviewCard v-model="open">
<template #trigger>Hover me</template>
<template #content>Preview</template>
</HoverPreviewCard>
</template>
Interactive and force-mounted content
Focus may move from trigger into teleported content without closing it. forceMount keeps closed content in DOM with hidden, inert, and closed-state hooks for custom transitions.
<HoverPreviewCard v-model="open" force-mount aria-label="Profile preview">
<template #trigger="{ triggerProps }">
<button v-bind="triggerProps">Open profile preview</button>
</template>
<template #content="{ close }">
<a href="/profile">View profile</a>
<button @click="close()">Close</button>
</template>
</HoverPreviewCard>
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "right" | "bottom" | "left" | "bottom" | Preferred side. |
align | "start" | "center" | "end" | "center" | Alignment on the cross-axis. |
sideOffset | number | 8 | Gap in px. |
openDelay | number | 600 | Delay before opening. |
closeDelay | number | 150 | Delay before closing. |
disabled | boolean | false | Prevents opening. |
forceMount | boolean | false | Keeps closed content mounted, hidden, and inert. |
openOnClick | boolean | true | Toggles on touch/pen click. Mouse continues to use hover/focus. |
arrow | boolean | false | Renders arrow element. |
ariaLabel | string | — | Adds labelled role="dialog" semantics for interactive previews. |
teleport | string | false | "body" | Teleport target. |
ui | HoverPreviewCardUi | — | Classes for structural parts. |
Emits
| Event | Payload | Description |
|---|---|---|
open-change | (open, details) | Fired before open state changes. |
Slots
| Slot | Props | Description |
|---|---|---|
trigger | isOpen, triggerProps | Trigger content. |
content | close | Preview content. |
UI Options
| Key | Description |
|---|---|
root | Root wrapper. |
trigger | Trigger wrapper. |
content | Floating card. |
arrow | Optional arrow. |
Styling Hooks
| UI key | CSS class | Data attrs |
|---|---|---|
root | akaza-hover-preview-card-root | data-akaza-state |
trigger | akaza-hover-preview-card-trigger | data-akaza-state |
content | akaza-hover-preview-card-content | data-akaza-state, data-akaza-side, data-akaza-align, aria-hidden, inert when force-mounted closed, --akaza-hover-preview-card-duration |
arrow | akaza-hover-preview-card-arrow | — |
Popup entry and exit use a subtle side-aware structural transition. Override --akaza-hover-preview-card-duration to change its 120ms duration. Reduced-motion preference shortens it automatically.
Keyboard
| Key | Behavior |
|---|---|
Tab / focus | Opens on trigger focus and remains open while focus is in trigger or content. |
Escape | Closes the card and returns focus to trigger. |