Skip to content

Hover card

A preview card on hover, on Base UI PreviewCard.

A preview of where a link goes. It opens for a pointer and for keyboard focus only: on a touch screen a tap follows the link and no card appears, so the card must never hold anything the page needs.

Default

Every colour, radius and type role comes from the foundation theme.

Placement

Installation

npx shadcn@latest add @khaeli/hover-card

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items
npm packages
  • @base-ui/react ^1.7.0

Keyboard

Tab
Focusing the link opens the card after the same short wait as hovering. Moving focus on closes it. Nothing inside the card can be reached with Tab, so keep links and buttons out of it.
Escape
Closes the card. Focus stays on the link.
Enter
Follows the link.

Accessible name

  • HoverCardTrigger is a link: it needs an href, and its text is its name.
  • The card has no role and is not tied to the link, so a screen reader is not told that it opened. Treat it as a visual preview and make sure the link's destination says the same.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/hover-card.json