Hover Card
For sighted users to preview content available behind a link.
Made by imskyleenPowered by
Installation
Loading component...
Positioning
Loading component...
When to use
Use this decision tree to determine when to use the Hover Card component:
Usage
<HoverCard>
<HoverCardTrigger>Hover Card Trigger</HoverCardTrigger>
<HoverCardContent>Hover Card Content</HoverCardContent>
</HoverCard>Props
Animate UI Props
HoverCardContent
Prop
Type
Keyboard interactions
| Key | Action |
|---|---|
Tab to HoverCardTrigger | Opens the hover card (keyboard-focus trigger). |
Shift+Tab off the trigger | Closes the hover card. |
Escape | Closes the hover card without moving focus. |
| Pointer hover / leave | Opens after openDelay, closes after closeDelay. |
Accessibility
- Hover cards are supplementary — put the same content on the page in an accessible form (link target, expandable section) so touch and reduced-motion users aren't excluded.
- The trigger must be a focusable element (
<a href>is typical since hover cards preview links). UseasChildto render the trigger as whatever semantic element you need. - Content is wired via
aria-describedbyso screen readers announce the preview when the trigger has focus. - Prefer
Popoverwhen the content contains interactive controls — hover cards auto-close on leave and interactive content becomes difficult to reach.
Controlled vs uncontrolled
Uncontrolled — typical case, hover cards time their own open/close:
<HoverCard>
<HoverCardTrigger asChild><a href="/users/bm">@malinskibeniamin</a></HoverCardTrigger>
<HoverCardContent>{/* preview card */}</HoverCardContent>
</HoverCard>Controlled — force open/closed for demos or during a guided tour:
const [open, setOpen] = useState(false);
<HoverCard open={open} onOpenChange={setOpen}>
<HoverCardTrigger asChild><a href="/users/bm">@malinskibeniamin</a></HoverCardTrigger>
<HoverCardContent>{/* preview card */}</HoverCardContent>
</HoverCard>Credits
- We use Base UI for the hover card component.
- We take our inspiration from Shadcn UI for the hover card style.
- We use Animate UI from imskyleen for all the animations.
Recent changes
- patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested b…#133
- minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
- minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
- majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
- minorv0.3.0Add theme-provider component to the registry with documentation and tests. Includes playground type improvements (export RegistryItem, remove as-const boilerplate) and docs site dark mode border color fix.#109
Built by malinskibeniamin. The source code is available on GitHub.