Keyframery

Hover Card

A preview card that unfolds from the link you are pointing at.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/hover-card

This adds components/keyframery/hover-card.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/keyframery/hover-card"

export default function Usage() {
  return (
    <HoverCard>
      <HoverCardTrigger href="/people/maya">@maya</HoverCardTrigger>
      <HoverCardContent>Maya Chen, product designer.</HoverCardContent>
    </HoverCard>
  )
}

Anatomy

How the parts fit together:

HoverCard
├── HoverCardTrigger
└── HoverCardContent

Examples

Profile preview

Shows after a short delay while the pointer rests on the link, or when it's focused. The link still works.

Faster or slower

delay is how long the pointer must rest before it opens, and closeDelay how long it lingers after.

Motion

MoveWhat you see
UnfoldThe card unfolds from the link you are pointing at.
CascadeIts contents arrive one after another.

Timing and springiness follow the motion style you set. To change how fast this hover card moves, pass speed:

<HoverCard speed="fast">
  …
</HoverCard>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--hover-card-surfaceCard and arrow surface--popover
--hover-card-inkCard text--popover-foreground
--hover-card-linkTrigger text--foreground
--hover-card-widthCard width18rem
--hover-card-radiusCard corners14px
--hover-card-paddingCard padding1rem

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK hover card reference.

HoverCard

Prop

Type

HoverCardTrigger

Renders a <a>, and takes its props too.

Prop

Type

HoverCardContent

Renders a <div>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • HoverCardArrow: a <div>

Keyboard

KeyWhat it does
TabOpens the card when the link gets focus.
EscapeCloses the card.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's hover card with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/hover-card"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/hover-card"

Questions

How does the animated Hover Card for UI SDK move?

Unfold: The card unfolds from the link you are pointing at. Cascade: Its contents arrive one after another.

Do I need Motion or Framer Motion for the animated Hover Card?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/hover-card instead. It has the same parts and props as @ui-sdk/react/hover-card and adds motion only.

What happens to the Hover Card when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page