Hover Card
A preview that appears while the pointer rests on a link, on the popover's glass.
"use client"
import { CalendarDaysIcon } from "lucide-react"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"
export default function HoverCardDemo() {
return (
<HoverCard>
<HoverCardTrigger href="#" className="text-mac-body font-medium text-mac-link hover:underline">
@johnappleseed
</HoverCardTrigger>
<HoverCardContent className="w-72">
<div className="flex gap-3">
<Avatar className="size-10">
<AvatarFallback className="bg-linear-to-b from-[#8ec5fc] to-[#3478f6] text-[15px]">JA</AvatarFallback>
</Avatar>
<div className="flex flex-col gap-1">
<span className="font-semibold">John Appleseed</span>
<span className="text-mac-label-secondary">Builds Mac apps with SwiftUI and the occasional web page.</span>
<span className="flex items-center gap-1 text-mac-subheadline text-mac-label-tertiary">
<CalendarDaysIcon className="size-3" /> Joined March 2019
</span>
</div>
</div>
</HoverCardContent>
</HoverCard>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/hover-cardThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"
<HoverCard>
<HoverCardTrigger href="/john">@john</HoverCardTrigger>
<HoverCardContent>…</HoverCardContent>
</HoverCard>API Reference
Every part forwards the props of the underlying Base UI Preview Card part. The props below are the ones CupertinoUI adds or changes.
HoverCardContent
| Prop | Type | Description |
|---|---|---|
side / align / sideOffset | | Where it opens. |
className | string | Extra classes, merged with the component's own. |