Card-layout hover

A set of five decorative, self-contained hover cards (HorizontalHoverCard, CompactHoverCard, WideHoverCard, StackedHoverCard, SplitHoverCard) that each open a differently laid-out card below a trigger on hover or focus. The surface uses ai2 tokens, sizes sm to xl, and drops its transform and transition when reduced motion is requested.

componentstyledhoverregistry-item.json
Card-layout hover
LIVE · running in a sandboxed iframe
Installed with shadcn add · 2 workarounds · theme from registry.json
  • applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
  • installed base item https://ai2.design/r/tokens.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @ai2/hover-card-layout

Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { HorizontalHoverCard } from "@/components/ui/hover-card-layout"<HorizontalHoverCard size="md" trigger={<span>@ai2</span>}>  Short profile summary.</HorizontalHoverCard>
  • Showing a profile, contact, or entity summary when a user hovers or focuses a name or link
  • Offering a quick preview of a concept, status, or metric without navigating away
  • Choosing among several decorative card layouts (horizontal, compact, wide, stacked, split) for a consistent styled hover system
  • Needing a hover card that respects prefers-reduced-motion without extra configuration

Examples

Profile hover with custom trigger

Uses HorizontalHoverCard with a custom trigger and custom card body text.

profile-hover-with-custom-trigger.tsx
import { HorizontalHoverCard } from "@/components/ui/hover-card-layout"export function ProfileExample() {  return (    <HorizontalHoverCard size="md" trigger={<span>@ai2</span>}>      A distributed component system you can trust.    </HorizontalHoverCard>  )}

Wide stats card with default content

Renders WideHoverCard at the lg size with no trigger or children, so the built-in "Hover me" button and default copy are shown.

wide-stats-card-with-default-content.tsx
import { WideHoverCard } from "@/components/ui/hover-card-layout"export function WideExample() {  return <WideHoverCard size="lg" />}

Split card with action footer

Uses SplitHoverCard at the xl size; the footer band with the Open pill is built in.

split-card-with-action-footer.tsx
import { SplitHoverCard } from "@/components/ui/hover-card-layout"export function SplitExample() {  return (    <SplitHoverCard size="xl" trigger={<span>Deployment</span>}>      Build finished without errors.    </SplitHoverCard>  )}

Compact inline hint

CompactHoverCard at the sm size for a dense, small hint next to a label.

compact-inline-hint.tsx
import { CompactHoverCard } from "@/components/ui/hover-card-layout"export function CompactExample() {  return (    <CompactHoverCard size="sm" trigger={<span>Note</span>}>      Dense single row.    </CompactHoverCard>  )}

API reference

PropTypeDefaultDescription
size"sm" | "md" | "lg" | "xl""md"Card width scale. Each layout maps this to its own width classes (Compact and Wide use their own scales).
triggerReact.ReactNodenullElement that receives hover and focus. When omitted, a fallback button labeled "Hover me" is rendered.
childrenReact.ReactNodenullContent shown inside the card. When omitted, each layout shows its own tokenized placeholder text.
classNamestringnullExtra classes applied to the card element (the popover shell), merged with the layout classes via cn.

Accessibility

  • The card element has role="dialog" and data-slot="styled-hover-card-content"; give it a meaningful accessible name through surrounding context, since no aria-label or aria-labelledby is set by the component.
  • The card is hidden with visibility and opacity when closed and becomes visible on group-hover and group-focus-within, so it is shown to pointer and keyboard users who focus inside the trigger wrapper.
  • Pass a focusable trigger (for example a button or link) when the card must be reachable by keyboard; the fallback trigger is a native button with type="button".
  • The trigger wrapper is a span with no tabindex, so a non-focusable custom trigger will not open the card via keyboard.
  • When the user prefers reduced motion (useReducedMotion from motion/react), the translate and transition classes are removed and the card appears instantly.
  • The fallback trigger shows a visible focus ring via focus-visible:ring-[3px] and ring-ring/50.
  • Text colors use foreground and muted-foreground token pairs for readable contrast on popover and secondary backgrounds.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Card-layout hover" component (ai2/hover-card-layout) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/hover-card-layout2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, trigger, children, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { HorizontalHoverCard } from "@/components/ui/hover-card-layout"<HorizontalHoverCard size="md" trigger={<span>@ai2</span>}>  Short profile summary.</HorizontalHoverCard>```

Files & dependencies

  • registry/ai2/styled/hover-card-layout.tsx→ components/ui/hover-card-layout.tsx
dependenciesmotion@^12.42.2lucide-react@^1.23.0
registryDependencies@ai2/tokens

Looks similar, elsewhere