Xzero UI
Pro library

Hover card

Preview a person or link on hover or focus without leaving the page.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/hover-card
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/hover-card

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { HoverCard, HoverCardProfile } from "@/components/xzero/hover-card/hover-card";

export function Mention() {
  return (
    <HoverCard
      content={<HoverCardProfile name="Maya Chen" role="Product designer, Payments" stats={[{ label: "Projects", value: 12 }]} />}
    >
      <button type="button">@maya</button>
    </HoverCard>
  );
}

API reference

HoverCard

A read-only preview that opens after a short hover or keyboard focus and stays open while the pointer travels into it.

PropTypeDefaultDescription
children (required)ReactElement–The trigger, such as a mention button or link. Must accept a ref and be focusable.
content (required)ReactNode–The preview. HoverCardProfile covers people.
side"top" | "bottom" | "left" | "right""bottom"Preferred side of the trigger.
align"start" | "center" | "end""start"Alignment against the trigger.
openDelaynumber500Milliseconds of hover before the first card opens.
closeDelaynumber140Grace in milliseconds after the pointer leaves.
classNamestring–Class on the card surface.

HoverCardProfile

A person preview: portrait, name, role, bio, stats, and a footer line.

PropTypeDefaultDescription
name (required)string–Full name. Initials are derived from it when there is no avatar.
rolestring–Role and team.
avatarstring | ReactNode–Portrait URL or your own image element such as next/image.
biostring–Short bio paragraph.
stats{ label: string; value: string | number }[][]Rendered as a definition list.
metaReactNode–Footer line such as location and local time.

Keyboard interactions

KeysAction
TabKeyboard focus on the trigger opens the card immediately.
EnterOpens the card without the hover delay.
EscapeCloses the card and keeps it closed while the pointer rests on the trigger.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in overlays

Guidance for AI tools

Hover card: Preview a person or link on hover or focus without leaving the page. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components