Overlays
Hover card
Preview a person or link on hover.
Usage
A rich preview of a link, shown on hover or keyboard focus. Compose HoverCard, a HoverCardTrigger (an <a>) and HoverCardContent. It opens after 700ms and closes 300ms after the pointer has left both the link and the card, so you can move onto the card.
Release notes for 2.4 were written by @adalovelace and reviewed by the design systems group.
When to use
- Extra context for a mention or link: a profile, a repository, a document.
- Only content that is also reachable by following the link. The card never opens on touch.
Not for: anything the person must act on (use a popover), or short labels (use a tooltip).
API
HoverCard
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial state when uncontrolled. |
| onOpenChange | (open: boolean) => void | — | Called when the card asks to open or close. |
| openDelay | number | 700 | Hover time before it opens, ms. |
| closeDelay | number | 300 | Time after leaving trigger and card before it closes, ms. |
HoverCardContent
| Prop | Type | Default | Description |
|---|---|---|---|
| placement | 'bottom' | 'top' | … (+ '-start' | '-end') | 'bottom' | Preferred side; flips when there is no room. |
| offset | number | 8 | Gap to the trigger, px. |
| arrow | boolean | false | Draw an arrow pointing at the trigger. |
HoverCardTrigger takes asChild to use your own link, such as a Next.js Link.
Keyboard
| Key | Action |
|---|---|
| Tab to the link | Opens the card straight away (no delay for keyboard focus). |
| Tab | Moves into the card when it holds links or buttons; leaving it closes the card. |
| Esc | Closes the card. |
Accessibility
- The card is supplementary: the trigger is a real link and must work without it.
- Keyboard focus on the link opens it; touch never does.
- Interactive content inside the card is reachable with Tab because the card follows the link in the DOM.
Motion
- Open: pops from the trigger side, 6px travel, scale .96 (220ms, ease-out). Close: 160ms fade.
- Reduced motion: it appears and disappears without movement.