Client component

Hover Card

A rich preview that opens on hover intent: the "profile card on a mention" pattern. Unlike Tooltip, the content is interactive: the close delay gives the pointer a grace period to travel into the card, and entering it cancels the close, so links and buttons inside are usable.

Mentioned by in the release notes.

Import#

import { HoverCard } from "astralis-ui";

Tooltip vs Hover Card#

  • Tooltip: a short text label, role="tooltip", pointer-events off.
  • HoverCard: a raised card with real content; supplementary by nature, so keyboard users get it on focus and the underlying link still works without it.

Props#

PropTypeDefaultDescription
open · defaultOpen · onOpenChangeboolean · boolean · (open: boolean) => voidNone · false · NoneControlled / initial state, and the change callback.
side"top" | "right" | "bottom" | "left""bottom"Preferred side of the trigger.
align"start" | "center" | "end""center"Alignment along that side.
sideOffsetnumber8Gap between the trigger and the card, in pixels.
avoidCollisionsbooleantrueFlips to the opposite side when the card would overflow the viewport.
openDelaynumber400How long the pointer must rest on the trigger before the card opens, in ms.
closeDelaynumber200Grace period for the pointer to travel into the card before it closes, in ms.

Parts#

PropTypeDefaultDescription
HoverCard.Triggerchildren: ReactElementNoneWraps a single element, typically a Link. Hover and focus open the card.
HoverCard.Contentdiv propsNoneThe raised card. Its content can be interactive.

Keyboard#

KeyAction
Tab onto the triggerOpen the card at once, with no delay
Tab off the triggerClose the card
EscClose the card

Because moving focus off the trigger closes the card, controls inside it can't be reached from the keyboard. Keep everything in the card available elsewhere, typically on the page the trigger links to.