GitHub

Hover Card

Card that appears on hover with preview content

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { HoverCard } from "@corew500/ui/hover-card"

<HoverCard>Content</HoverCard>

CMS Integration

CMSPayload CMS Integration
This component supports CMS-driven content via @corew500/cms-payload.
Loading...

API Reference

Props

PropTypeDefaultDescription
defaultOpenenumfalseWhether the preview card is initially open. To render a controlled preview card, use the `open` prop instead.
openenumWhether the preview card is currently open.
onOpenChange(open: boolean, eventDetails: PreviewCardRootChangeEventDetails) => voidEvent handler called when the preview card is opened or closed.
onOpenChangeComplete(open: boolean) => voidEvent handler called after any animations complete when the preview card is opened or closed.
actionsRefRefObject<PreviewCardRootActions>A ref to imperative actions. - `unmount`: Unmounts the preview card popup. - `close`: Closes the preview card imperatively when called.
handlePreviewCardHandle<unknown>A handle to associate the preview card with a trigger. If specified, allows external triggers to control the card's open state. Can be created with the PreviewCard.createHandle() method.
triggerIdstringID of the trigger that the preview card is associated with. This is useful in conjuntion with the `open` prop to create a controlled preview card. There's no need to specify this prop when the preview card is uncontrolled (i.e. when the `open` prop is not set).
defaultTriggerIdstringID of the trigger that the preview card is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open preview card.

Accessibility

Keyboard Navigation

  • - Content is accessible via keyboard focus (appears on focus)

Focus Management

  • Not modal - does not trap focus
  • Content dismissed when focus/pointer leaves

Screen Readers

  • Trigger uses appropriate ARIA attributes

Additional

  • Touch devices: opens on long press

Localization

Translatable Content

  • - Component accepts pre-resolved strings for all text content
  • Content children should contain translated text