Hover Cards
An editorial portrait row that opens the hovered card into a tall focal image while a blurred, full-bleed version of the same artwork washes across the stage. Pointer, keyboard, and tap interactions share the same responsive composition.
Installation#
pnpm dlx shadcn@latest add @davinciui/hover-cardsUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
itemsPortrait source, alt text, label, description, crop position, and optional active-backdrop text tone for each card. | readonly HoverCardsItem[] | — |
titleCentered title above the portrait row. | ReactNode | "Hover Cards" |
activeIndexControlled active card. Pass null for the idle layout. | number | null | — |
initialActiveIndexInitial active card for uncontrolled usage. | number | null | null |
onActiveIndexChangeCalled when pointer, keyboard focus, or tap changes the active card. | (index: number | null) => void | — |
clearOnLeaveRestore the equal-width idle row when a mouse leaves the composition. | boolean | true |
backdropBlurBlur radius, in pixels, for the expanded background image. | number | 44 |
autoPlayAuto-advance through cards on a timer. Pauses offscreen, in background tabs, and while hovered or focused. | boolean | false |
autoPlayIntervalAuto-play interval in milliseconds (minimum 800). | number | 3000 |
pauseAutoPlayOnHoverPause auto-play while the pointer hovers or focus is inside the composition. | boolean | true |
showTextHide the title, index numbers, labels, and descriptions for compact previews. | boolean | true |
classNameAdditional classes for sizing and styling the stage. | string | — |
Accessibility#
Cards are buttons inside a labelled list, with aria-pressed and an aria-label combining label and description. Focus activates a card, focus-visible rings are shown, and auto-play pauses on hover, focus, background tabs and offscreen; background art is aria-hidden.
Motion#
The active card grows via flex-grow and the blurred backdrop crossfades opacity and scale over 680ms with cubic-bezier(0.22,1,0.36,1). useReducedMotion sets all transition durations to 0ms and disables auto-play; the image scale also has motion-reduce:transition-none.
Customization#
Set the stage height with className; card heights, gaps, and label offsets scale from the measured stage. Use backdropBlur for the full-bleed image and showText={false} for an image-only strip.
Styling slots
[data-slot="hover-cards"]View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

