Skip to content

Hover Card

A preview that opens when the pointer rests on a link or focus lands on it. It stays open while you move into it. On a touch screen the first tap shows the card and the second follows the link.

On this page
Used for
  • Agent profile preview
  • Run link preview
  • Mention details
  • Model info on hover

Examples

Installation

npx knowns-ui@latest add hover-card
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

trigger
ReactElement
One element, usually a link. It gets aria-describedby while the card is open.
children
ReactNode
The card. Without `interactive` it cannot be reached with Tab, so keep it informational: nothing here may be the only way to something.
interactive
boolean
Defaultfalse
The card holds buttons or links. Tab from the focused trigger moves into the card; Tab past its last control or Shift+Tab from its first returns to the page order and closes it. No focus trap. The trigger gets aria-haspopup="dialog" and aria-controls instead of aria-describedby, and the card is a labelled, non-modal dialog.
label
string
Accessible name of an interactive card. Default: the trigger's own text.
openDelay / closeDelay
number (ms)
Default500 / 200
Rest time before opening. Time to cross the gap into the card before it closes. Focus opens it at once.
side / align
"top" | "bottom" | "left" | "right" / "start" | "center" | "end"
Default"bottom" / "center"
Placement; it flips when there is no room.
open / onOpenChange
boolean / (open) => void
Optional control.
width
number
Default288
Card width in px, never wider than the screen.
touch
behaviour
No hover on touch: the first tap opens the card and holds the link back, a tap while open follows it, a tap outside closes it.
keys
Escape / Tab / Shift+Tab
Escape closes the card and, from inside an interactive card, returns focus to the trigger. Tab and Shift+Tab move through an interactive card as above.

What it handles

  1. 01Opens a preview card after the pointer rests on the trigger for openDelay, half a second by default, and opens at once on keyboard focus.
  2. 02Stays open while the pointer is over the trigger or the card, and closes closeDelay after it leaves, a fifth of a second by default.
  3. 03Closes on Escape or a press outside. Read-only, the trigger is described by the card while it is open; interactive, it announces a labelled non-modal dialog (aria-haspopup, aria-controls).
  4. 04With interactive, Tab from the trigger enters the card, and Tab past its last control or Shift+Tab from its first leaves it and closes it, with no focus trap.
  5. 05Treats the first touch tap as the open, so a link trigger does not navigate until the second tap.
  6. 06Renders in a portal with side, align and a width in pixels, and flips when the card would run off screen.

States

First render
Nothing. The card is not mounted until it opens
none
Pointer rests
After the open delay the card fades in
120ms, opacity only
Pointer leaves
After the close delay the card fades out a little quicker
120ms, opacity only
Keyboard focus
The card opens at once with the same fade
120ms, opacity only
Tab into the card
Interactive only: focus moves to its first control, nothing animates
none
Reduced motion
It appears and unmounts at once
0ms

Works with

When to use

When to use

  • A preview of the thing a link points to: a profile, a run, a repository, shown when the pointer rests on it.

When not to use

  • A short label for an icon button: use Tooltip.
  • Information people must have, or content that opens on a click: use Popover.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Hover Card to my app and wire it to my own data.
  • I need a preview of the thing a link points to: a profile, a run, a repository, shown when the pointer rests on it. Set that up with the Knowns UI Hover Card.
  • Which Hover Card props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "hover-card" }) and search_docs({ query: "hover card" }).

Need help?

Stuck on Hover Card, or found something off? We read every message.