Rime

HoverCard

A rich preview on hover or keyboard focus of a link: a person, a project, a record.

HoverCard opens after a short delay (openDelay, 500ms) when the pointer rests on its trigger or the trigger takes keyboard focus, and closes a little after the pointer leaves (closeDelay, 200ms), so the pointer can travel onto the card. Touch never opens it: the trigger must work on its own.

The card is supplementary. It is tied to the trigger with aria-describedby while open and Esc dismisses it.

inline renders the open panel in the page flow: no portal, scrim, focus trap, scroll lock or outside-click listener. It exists for docs, previews and static mock-ups; never ship it as the live overlay.

Installation

npx shadcn@latest add KezLahd/rime/hover-card

Also installs: base, popover.

Usage

import { HoverCard } from "@/components/ui";

<HoverCard trigger={<a href="/team/jane-cooper">@janecooper</a>}>
  …profile…
</HoverCard>

Examples

Open

@janecooper

On hover and focus

Hover the name, or Tab to it.

Assigned to @janecooper for review. Hover or focus the name.

API

Generated from the component's TypeScript types and JSDoc (scripts/gen-ui-registry.mjs), so it always matches the source.

HoverCard

HoverCard props
PropTypeDefaultDescription
triggerRequiredReactElement<TriggerProps>A link or button the card previews: a person's name, a project, a reference.
childrenRequiredReactNodeThe preview: a few lines of supporting detail. Never the only route to an action.
openDelaynumber500ms of hover or focus before it opens.
closeDelaynumber200ms after the pointer leaves before it closes, so it can travel onto the card.
sideFloatSide"bottom"
alignFloatAlign"start"
widthnumber300Panel width in px.
inlinebooleanRender the card open in the page flow under the trigger (docs, previews).
classNamestring

Theme tokens

Per-component tokens are undeclared by default, so the default shown is the fallback the CSS uses. Set one at :root (or in theme.css) to restyle every instance. Live values are read from this page, so they follow the Rime Studio.

HoverCard per-component tokens
TokenDefaultLive value
--hover-card-padcalc(16px * var(--density))…
--hover-card-radiusvar(--r-lg)…

System tokens it reads

HoverCard system tokens
TokenDefaultLive value
--border-wtokens.css…
--densitytokens.css…
--durtokens.css…
--dur-slowtokens.css…
--ease-outtokens.css…
--ink-bodytokens.css…
--popover-blurtokens.css…
--popover-bordertokens.css…
--popover-shadowtokens.css…
--popover-surfacetokens.css…
--r-lgtokens.css…
--text-smalltokens.css…
--z-popovertokens.css…

Accessibility

  • Opens on keyboard focus as well as hover, and the card describes its trigger (aria-describedby).
  • Esc closes it. Nothing inside it should be the only way to reach an action.
  • Respects reduced motion: it fades in place.

Do and don't

Do

  • Use it on links whose target needs a glance before a click: people, projects, references.

Don't

  • Don't put buttons or forms in a hover card; use Popover.
  • Don't use it on touch-first screens as the only way to see the detail.

For AI agents

This page as markdown, rendered from the same registry entry. Point an agent at it (or add .md to this page's URL), or at /llms.txt for the index.

Open hover-card.md

Related: popover, tooltip, avatar