Components
Hover card
A preview card that appears when hovering or focusing a link or name.
Free
pnpm dlx shadcn@latest add @caliper/hover-cardWhen to use
Use it for
- Previewing a person, project or link without leaving the page.
- Supplementary detail that is also available on its own page.
Skip it when
- The information is essential; it is invisible on touch.
Installation
terminal
pnpm dlx shadcn@latest add @caliper/hover-card
Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above. It is built from HoverCard and HoverCardProfile.
example.tsx
import { type ReactNode } from "react" import { Avatar } from "@/components/ui/avatar" import { HoverCard, HoverCardProfile } from "@/components/ui/hover-card" import { cn } from "@/components/ui/lib/cn" function Panel({ title, context, media, action, className, children }: { title: string; context: string; media?: ReactNode; action?: ReactNode; className?: string; children?: ReactNode }) { return ( <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}> <div className="flex items-center gap-3"> {media} <div className="grid min-w-0 flex-1 gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {action} </div> {children} </section> ); } export function MentionCard() { return ( <Panel title="Room pages · review" context="3 comments · last 2 hours ago"> <div className="flex gap-3"> <Avatar name="Noor Haddad" alt="" /> <div className="grid gap-1 text-sm"> <p><span className="font-medium">Noor Haddad</span> <span className="text-muted-foreground">· 2h</span></p> <p className="leading-6"> The build is on staging.{" "} <HoverCard content={<HoverCardProfile name="Mara Chen" role="Leads the copy" bio="Reviews the harbour room pages before they go to the stay team." stats={[{ label: "Projects", value: 4 }, { label: "Reviews", value: 27 }]} />}> <button type="button" className="font-medium text-[var(--accent-text)] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring">@mara</button> </HoverCard>{" "} can you check the room copy before Friday? </p> </div> </div> </Panel> ); }
API reference
HoverCard
component
PropTypeDefault
content *ReactNode—
children *ReactNode—
openDelaynumber500
closeDelaynumber140
classNamestring—
HoverCardProfile
component
PropTypeDefault
name *string—
rolestring—
biostring—
statsreadonly { label: string; value: string | number; }[][]
Accessibility
It exposes tooltip semantics, with aria-describedby kept in step with state.
KeyBehaviour
EnterActivates the focused control.
EscapeCloses or cancels, then returns focus to where it came from.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.