HoverCard

A preview card shown after a short delay when a link is hovered or focused: a profile, a repository, a page summary.

BetaSource

Reviewed by @ada two hours ago.

Import

import { HoverCard } from "@meridui/react";

Anatomy

<HoverCard.Root>
  <HoverCard.Trigger />
  <HoverCard.Content />
</HoverCard.Root>
  • Root holds the open state and the delays. It renders no element.
  • Trigger is an <a>; with asChild it merges onto your own Link or router link.
  • Content is the portalled card, positioned against the trigger. It only mounts while open.

Examples

Delays and placement

openDelay (default 500ms) avoids flashing cards while the pointer passes by; closeDelay (default 300ms) lets the pointer travel from the link onto the card, which stays open while hovered.

API reference

Root

PropTypeDefaultDescription
openboolean–Controlled open state.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void–Called when the open state should change.
openDelaynumber500Delay before opening on hover or focus, in ms.
closeDelaynumber300Delay before closing after the pointer leaves, in ms.

Trigger

Accepts every <a> attribute.

PropTypeDefaultDescription
asChildbooleanfalseRender the single child element (e.g. your own Link) instead of an <a>, merging props, ref and handlers.
refRef<HTMLAnchorElement>–Forwarded ref.

Content

Accepts every <div> attribute.

PropTypeDefaultDescription
placementPlacement"bottom"Preferred placement relative to the trigger.
sideOffsetnumber8Distance from the trigger in px.
containerElement | nulldocument.bodyPortal target.
refRef<HTMLDivElement>–Forwarded ref to the card.

Styling

ClassElement
.mrd-hover-cardContent
AttributeOnValues
data-stateTriggeropen, closed
data-stateContentopen

Accessibility

A hover card is supplementary: it opens on hover and on keyboard focus, but screen readers are not told about it and its content is not in the Tab order. The trigger must make sense on its own (the link goes to the full profile), and nothing essential or interactive should live only in the card. Touch hover is ignored. For interactive content, use a Popover.

KeyAction
TabFocusing the trigger opens the card after openDelay; leaving closes it.
EscapeClose the card.

Guidelines

Do

Preview something the link points to: who a person is, what a repository contains.

Avoid

Put buttons, forms or the only copy of information in a hover card.

  • Tooltip: a short text label for a control.
  • Popover: a click-opened panel that can hold interactive content.