Primitive / Moleculebeta
Hover Card
Preview card that appears on hover or focus with configurable delays and placement.
@glinui/uiComponent: hover-card
Installation
Install from the package for shared ownership or from the registry for copy-paste control.
Package Manager
pnpm add @glinui/ui @glinui/tokensRegistry
pnpm dlx @glinui/cli@latest add hover-cardUsage
Basic
TSX
1import { Avatar, HoverCard, HoverCardContent, HoverCardTrigger } from "@glinui/ui"23export function Demo() {4 return (5 <HoverCard>6 <HoverCardTrigger asChild>7 <button className="inline-flex items-center gap-2 text-sm font-medium underline decoration-dotted underline-offset-4">8 <Avatar fallback="GL" size="sm" />9 @glinui10 </button>11 </HoverCardTrigger>12 <HoverCardContent>13 <div className="space-y-1">14 <p className="text-sm font-semibold">@glinui</p>15 <p className="text-xs text-neutral-600 dark:text-neutral-300">16 Glass-first component system for modern interfaces.17 </p>18 </div>19 </HoverCardContent>20 </HoverCard>21 )22}
Surface and Delays
TSX
1import { Badge, HoverCard, HoverCardContent, HoverCardTrigger } from "@glinui/ui"23export function Demo() {4 return (5 <div className="flex flex-wrap items-center gap-4">6 <HoverCard openDelay={0} closeDelay={150}>7 <HoverCardTrigger asChild>8 <button className="text-sm font-medium underline decoration-dotted underline-offset-4">9 Instant preview10 </button>11 </HoverCardTrigger>12 <HoverCardContent variant="glass" size="sm">13 <div className="space-y-2">14 <Badge variant="glass">glass</Badge>15 <p className="text-xs text-neutral-600 dark:text-neutral-300">Open delay: 0ms</p>16 </div>17 </HoverCardContent>18 </HoverCard>19 <HoverCard openDelay={500} closeDelay={250}>20 <HoverCardTrigger asChild>21 <button className="text-sm font-medium underline decoration-dotted underline-offset-4">22 Delayed preview23 </button>24 </HoverCardTrigger>25 <HoverCardContent variant="outline" size="md">26 <p className="text-xs text-neutral-600 dark:text-neutral-300">27 Opens after 500ms with outline surface.28 </p>29 </HoverCardContent>30 </HoverCard>31 </div>32 )33}
Accessibility
- Built on Radix Hover Card and opens on hover and keyboard focus.
- Hover card content should be supplemental; avoid critical-only information.
- Use non-interactive preview content for concise summaries.
Keyboard Interactions
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move focus to or away from the trigger. |
| Escape | Close the hover card when focused. |
ARIA Attributes
- `aria-describedby` linkage is handled by Radix primitives
- Trigger remains semantic and keyboard reachable
Reduced Motion
Entrance and exit transitions are disabled under `prefers-reduced-motion`.
Affected properties
opacitytransformAPI Reference
HoverCardProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
openDelay | number | No | 200 | Delay in milliseconds before opening on hover/focus. |
closeDelay | number | No | 100 | Delay in milliseconds before closing after pointer leaves. |
open | boolean | - | - | Controlled open state. |
defaultOpen | boolean | - | - | Initial open state for uncontrolled usage. |
onOpenChange | (open: boolean) => void | - | - | Open state change handler. |
HoverCardContentProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | "default" | "glass" | "outline" | "ghost" | No | glass | Visual surface treatment. |
size | "sm" | "md" | "lg" | No | md | Content width and density scale. |
align | "start" | "center" | "end" | - | center | Alignment relative to the trigger. |
side | "top" | "right" | "bottom" | "left" | No | bottom | Preferred side for content placement. |
sideOffset | number | No | 10 | Distance from trigger in pixels. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { HoverCard } from "@glinui/ui"Source Files
Dependencies
@glinui/uiGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/hover-card.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-02-19T17:59:28.468Z · Full index: /docs/api-metadata
Primary Props Type
HoverCardProps
HoverCardContentProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
side | "top" | "right" | "bottom" | "left" | No | - | Preferred side for the hover card. |
sideOffset | number | No | 10 | Gap in px between trigger and content. |
size | "sm" | "md" | "lg" | No | "md" | Variant option from hoverCardContentVariants. |
variant | "default" | "glass" | "outline" | "ghost" | No | "glass" | Variant option from hoverCardContentVariants. |
HoverCardProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
closeDelay | number | No | 100 | Delay in ms before closing when pointer leaves. |
openDelay | number | No | 200 | Delay in ms before opening on pointer/focus. |