Hover Card
A hover preview panel with intent delays, four sides, alignment control, keyboard support, and RTL.
Installation#
pnpm dlx shadcn@latest add @davinciui/hover-cardUsage#
Composition
A trigger wrapped in hover intent drives one floating panel. Side, alignment, gap, and both delays are props — focus, Escape, click-toggle, and outside dismissal come built in.
Composition#
Use the following composition to build a Hover Card:
HoverCard
├── HoverCardTrigger
└── HoverCardContentAPI Reference#
| Prop | Type | Default |
|---|---|---|
openControlled open state. | boolean | — |
defaultOpenUncontrolled initial open state. | boolean | false |
onOpenChangeFires when the card opens or closes. | (open: boolean) => void | — |
openDelayHover intent delay before opening, in ms. | number | 500 |
closeDelayGrace delay before closing, in ms. | number | 250 |
sidePanel side relative to the trigger. | "top" | "right" | "bottom" | "left" | "top" |
alignPanel alignment along the side. | "start" | "center" | "end" | "center" |
sideOffsetGap between trigger and panel in px. | number | 8 |
showArrowConnector arrow pointing at the trigger. | boolean | true |
dirText direction. | "ltr" | "rtl" | "ltr" |
classNameExtra classes for the wrapper. | string | — |
Accessibility#
Built on Base UI Preview Card: the trigger is focusable and opens the panel on focus, Escape dismisses it, and the popup uses role=dialog with a fixed aria-label of Preview. The trigger has a focus-visible ring, and a safe polygon lets pointer travel reach the panel.
Motion#
The panel animates opacity, scale and translate over 150ms with cubic-bezier(0.23,1,0.32,1) using starting and ending styles. openDelay and closeDelay control hover intent rather than animation; motion-reduce removes the transition, translation and scale.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

