Skip to content
English

How it works

The card is placed in layout pixels against the closest element marked data-ds-boundary, or the viewport: it flips above when there is no room below, shifts sideways to stay inside, and moves its arrow by the same amount so it still points at the trigger. A transparent bridge covers the gap so the pointer can reach the card.

Use it for

  • Previewing a person, a link or a record without leaving the page.
  • Optional context that sighted pointer users benefit from.

Look elsewhere when

  • Essential information or actions: they must also be reachable another way, since touch has no hover.
  • Short text labels: use a tooltip.

Usage

import { HoverCard } from './HoverCard.jsx'

export function Mention() {
  return (
    <HoverCard label="Profile of Mara Lin" content={<ProfilePreview id="mara" />}>
      <a href="/people/mara">@mara.lin</a>
    </HoverCard>
  )
}

Props

PropTypeDefaultWhat it does
childrenReactElement—The trigger, usually a link; it receives aria-describedby while the card is open.
contentReactNode—The card body. Use inline elements (span) when the trigger sits inside a paragraph.
labelstring—Accessible name of the card.
openDelaynumber500Pointer rest time in ms before opening; keyboard focus waits at most 300.
closeDelaynumber220Grace period in ms after the pointer leaves.
side'bottom' | 'top''bottom'Preferred side; flips when there is no room.
defaultOpenbooleanfalseOpen on first render.

Accessibility

  • The card opens on keyboard focus as well as hover, and the trigger gets aria-describedby pointing at it.
  • The card is a non-modal role dialog placed right after the trigger, so Tab moves into its buttons; leaving the card closes it.
  • Escape closes the card and returns focus to the trigger.
  • Touch input does not open it; the link keeps working as a link.
  • With reduced motion the card only fades and the delay underline appears without animating.

Motion

Open after 500ms with a linear underline fill; enter 220ms cubic-bezier(0.32, 1.2, 0.5, 1) from 0.96 scale and 4px, scaled from the arrow; leave 130ms.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

HoverCard.jsxhover-card.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Overlays
Bottom sheet comes with Pro. Its preview shows once you unlock it.