UI

Hover card

Preview a person or linked resource on hover or keyboard focus without leaving the page.

import { HoverCard } from '@uthereal/ui/hover-card'

Hover card playground

Loading interactive preview…

Overview

HoverCard displays a read-only preview panel anchored to a trigger after a short hover delay or immediate keyboard focus, and keeps the card open while the pointer moves into it. Pass a structured profile (or <HoverCardProfile> as React children) to render Arc's person preview—portrait or initials, name, role, bio, stats, and footer metadata—or pass title, description, and custom children for a page or citation preview.

A hover card is supplemental. Focus never moves into the card and touch users may never open it, so never place required information or interactive actions inside it. Use a Dialog or Drawer for interactive panels and a Hover message for one-line hints.

Usage

'use client'
import { HoverCard, HoverCardProfile } from '@uthereal/ui/hover-card'

export function Mention() {
  return (
    <HoverCard
      renderTrigger={(props) => (
        <button {...props} type="button">
          @maya
        </button>
      )}
    >
      <HoverCardProfile
        name="Maya Chen"
        role="Product designer, Payments"
        bio="Leads checkout and billing design. Usually reviews files within a day."
        stats={[
          { label: 'Projects', value: 12 },
          { label: 'Reviews', value: 48 },
        ]}
        meta="Lisbon · 14:20 local time"
      />
    </HoverCard>
  )
}

Use profile for serializable data (agent configs and JSON schemas) or <HoverCardProfile> as React children when you need custom React elements in avatar (such as next/image) or meta (such as a leading icon).

renderTrigger(props, state) renders a custom trigger such as a link or mention button: spread all props onto a focusable element and keep the supplied id. Without renderTrigger, the serializable trigger prop renders a Button; its icon accepts any name from the icon list.

Examples

Resource content

The playground above renders a profile card. Set title and description to preview a linked document, changelog, or source instead.

Compact width

sm (240 px) fits a compact title and single line compared with the default md (296 px) card. Both widths clamp to calc(100vw - 24px).

Timing and warm handoff

EventTimingBehavior
Cold hoveropenDelay (500 ms)Waits before opening so passing pointers do not flash the card.
Warm handoff80 ms intent inside 300 ms skip windowWhile another hover card is open or closed within 300 ms, the next card opens after 80 ms and fades in over 90 ms without travel.
Pointer leavecloseDelay (140 ms)Grants time to travel from trigger into the card; re-entering mid-exit reverses the close in place.
Click, Enter, :focus-visibleImmediateOpens without delay. On touch devices, tapping the trigger toggles the card.
EscapeImmediateCloses the card and suppresses reopen until the pointer leaves or focus blurs.

Only one HoverCard stays open on the page at a time. Opening a second card closes the active one immediately.

Controlled state

Omit open to manage visibility internally, or pass open and onOpenChange for controlled state. onOpenChange fires in both modes. A server-rendered defaultOpen card opens after client hydration and emits onOpenChange(true).

API reference

Serializable arguments and defaults come directly from hoverCardConfigSchema.

ArgumentType / defaultDescription
triggerOverlayTriggerDefault: {"label":"Show preview","variant":"outline","tone":"neutral","size":"md"}The button that shows the card when no React trigger is supplied: label, optional icon, variant, tone and size.
profileHoverCardProfile—Arc's person preview: name (initials stand in for a missing avatar), role, avatar image URL, bio, up to six stats shown value above label, and a quiet meta footer line. Its rows settle in one after another. Shown above the title, description and children.
titlestring—Heading of the preview, e.g. a linked page or source, at 16 pixels.
descriptionstring—Preview text under the title.
widthsm | mdDefault: "md"Card width: 240 or 296 pixels (Arc's 18.5rem), never wider than the viewport.
placementPlacementDefault: "bottom-start"Preferred side of the trigger, bottom-start by default as in Arc. Collision detection flips it when there is no room.
openDelayintegerDefault: 500Hover time before the first card opens, in milliseconds (500), so passing the pointer over the trigger does not flash it. While another card is open or just closed, the next opens after 80 ms and only fades. Keyboard focus, a click and a tap open at once.
closeDelayintegerDefault: 140Time before the card closes after the pointer leaves, in milliseconds (140). Moving into the card keeps it open.
defaultOpenbooleanDefault: falseInitial open state. Later argument edits do not reset an existing instance.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeHoverCardTheme—Color mode, accent, and tokens for the card. The default trigger takes the mode and accent. See Theming for all keys and defaults.
motionnone | subtle | expressiveDefault: "subtle"Card and row animation preset. System reduced-motion preferences take precedence.
motionOptionsHoverCardMotionOptions—Popup transition, and entrance and exit poses. Exits run faster than entrances. Durations are milliseconds.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
childrenCard body rendered after profile, title, and description. Accepts <HoverCardProfile> or custom read-only markup.
renderTrigger(props, state)Renders a custom focusable trigger; spread props and preserve id.
open, onOpenChange(open)Controlled open state and change callback.
presetApplication defaults merged below instance props.
renderIcon(name, context)Replaces the default trigger icon (slot: 'trigger'). Keep decorative.
tokens--ui-* CSS variables applied after the typed theme on trigger and card.
classNameAdded to the portalled card surface.
portalContainerMount target for nesting inside a native modal top layer.

HoverCardProfile props

PropTypePurpose
namestringRequired full name; initials derive from its first two words.
rolestringSecondary role and team line below the name.
avatarstring | ReactNodePortrait image URL (fades from a soft blur while loading) or custom image element; initials show when omitted.
biostringShort biography paragraph.
statsHoverCardStat[]{ label: string; value: string | number }[] rendered value above label.
metaReactNodeQuiet footer row (supports inline icons via flex alignment).

Keyboard & accessibility

KeyInteraction
TabKeyboard focus (:focus-visible) on the trigger opens the card immediately.
EnterOpens the card without delay when the trigger is focused.
EscapeDismisses the card from anywhere on the page; focus stays on the trigger.

The card exposes role="tooltip" and attaches to its trigger via aria-describedby while open. It satisfies WCAG 1.4.13 (Content on Hover or Focus): dismissible with Escape, hoverable without closing, and persistent until hover or focus leaves. Focus never enters the card. Layout, stats alignment, and placement flip automatically under dir="rtl". Under forced-colors: active, the card keeps a ButtonText border.

Motion and theming

On a cold open, the card grows from the trigger edge—scaling from 0.96 with 4 px of travel on the smooth spring (motionTokens.spring.smooth) while a 160 ms fade leads—and exits back in 120 ms. Warm cards stay stationary and fade in over 90 ms. Rows (profile head, bio, stats, meta, title, description, and children) settle upward 4 px over 240 ms, staggered 35 ms apart after a 40 ms delay. Uncached portraits fade in from a 4 px blur. Re-entering a closing card turns the animation around from its current pose without remounting.

motionOptions customizes popup transition, enter, and exit poses (durations in ms). Setting motion="none" removes all card, row, and portrait transitions (0 ms). Under prefers-reduced-motion: reduce, travel, scale, row stagger, and portrait blur stop while the card keeps a short opacity fade (150 ms in, 100 ms out).

theme accepts mode, accent, the core token group, popupRadius, borderSubtle, and component token padding (16 px in studio, 20 px in soft). The default trigger inherits mode and accent.

Composition

In agent compositions, HoverCard is a container whose children render inside the preview panel and whose trigger comes from trigger.

{
  "type": "HoverCard",
  "props": {
    "trigger": { "label": "Maya Chen", "variant": "ghost" },
    "profile": {
      "name": "Maya Chen",
      "role": "Product designer, Payments",
      "stats": [{ "label": "Projects", "value": 12 }]
    }
  },
  "children": []
}

On this page