Hover Preview Card
Hover-triggered rich content preview for links, users, and entities.
HoverPreviewCard opens preview content from hover or focus after a delay. Use Popover for click-to-open content.
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.
import './main.css'
Controlled open state
Bind v-model when another interaction should own the card state.
<template>
<Accordion
:items="items"
type="multiple"
/>
</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.
<Dialog
:ui="{
overlay: 'fixed inset-0 bg-black/50',
content: 'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white p-6',
}"
/>
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 transitions follow their placement side and last 120ms. Set --akaza-hover-preview-card-duration to change the duration. Reduced-motion mode removes the visible transition.
Positioning Variables
The card and its arrow update together when the trigger, content, or viewport changes size. Placement can switch sides to fit the viewport.
| Variable | Meaning |
|---|---|
--akaza-hover-preview-card-anchor-width | Anchor width in pixels. |
--akaza-hover-preview-card-anchor-height | Anchor height in pixels. |
--akaza-hover-preview-card-available-width | Viewport width after collision padding. |
--akaza-hover-preview-card-available-height | Viewport height after collision padding. |
--akaza-hover-preview-card-transform-origin | Origin matching the resolved side and alignment. |
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. |