EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
HoverCard·component·@astryxdesign/core

Hover Card

HoverCard shows additional information when the user hovers or focuses a trigger element. Use it for profile cards, link summaries, or inline definitions where the user needs more context without navigating away.

Open in Playground @astryxdesign/core/HoverCard

Showcases and examples

4 documented examples

Hover Card

A hover card that shows a user profile preview when hovering over a trigger button. Starts open for preview.

Preview loads on approachPreview loads on approach
Exact source · hover-card-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {HoverCard} from '@astryxdesign/core/HoverCard';
import {Button} from '@astryxdesign/core/Button';
import {Stack} from '@astryxdesign/core/Layout';
import {Text, Heading} from '@astryxdesign/core/Text';
import {Avatar} from '@astryxdesign/core/Avatar';

export default function HoverCardShowcase() {
  return (
    <HoverCard
      placement="above"
      content={
        <Stack direction="vertical" gap={2} style={{width: 240}}>
          <Stack direction="horizontal" gap={2} vAlign="center">
            <Avatar name="Jane Doe" size="lg" />
            <Stack direction="vertical" gap={0}>
              <Heading level={5}>Jane Doe</Heading>
              <Text type="supporting" color="secondary">
                Software Engineer
              </Text>
            </Stack>
          </Stack>
          <Text type="body" color="secondary">
            Building great products with great people.
          </Text>
        </Stack>
      }>
      <Button label="@janedoe" variant="ghost" />
    </HoverCard>
  );
}

Usage

HoverCard shows additional information when the user hovers or focuses a trigger element. Use it for profile cards, link summaries, or inline definitions where the user needs more context without navigating away.

  • Keep content supplementary; hover cards should enhance understanding without blocking the primary workflow.
  • Provide a dashed underline on text triggers so users know the element is hoverable.
  • Use the hook API (useHoverCard) when you need more control over timing or placement.
  • Leave touchTrigger on auto so a tap opens the card on triggers that do nothing else, and stays out of the way on triggers that perform an action.
  • Place critical actions or required information inside a hover card; users may miss content that only appears on hover.
  • Use a hover card when a simple Tooltip or Popover would suffice.
  • Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.
  • Prefer placing HoverCard in a block context rather than directly in a <p>, heading, or link. Those placements are supported when necessary through a corrective portal, but the DOM and tab order may differ.

Typed props

PropType and behavior
childrenReactNode
Trigger element that must accept a ref.
contentReactNode · required
Hover card content.
Slot: Text
placement'above' | 'below' | 'start' | 'end' · default 'above'
Position relative to the anchor element. Logical: start/end resolve against the popover's own inherited direction (RTL mirrors in pure CSS).
alignment'start' | 'center' | 'end' · default 'center'
Alignment along the placement axis. Logical: start/end resolve against the popover's own inherited direction (RTL mirrors in pure CSS).
delaynumber · default 300
Show delay in milliseconds.
hideDelaynumber · default 200
Hide delay in milliseconds.
focusTrigger'auto' | 'always' | 'never' · default 'auto'
Controls when focus events trigger the hover card.
touchTrigger'auto' | 'tap' | 'none' · default 'auto'
What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (a button, link, or form control), whose tap belongs to the control. tap always opens. none never opens on touch. A tap-opened card is dismissed by a tap outside it.
isEnabledboolean · default true
Enables or disables the hover and focus triggers.
labelstring
Accessible name for the hover card popup. When provided, the popup is exposed as a named role="dialog"; when omitted, it falls back to role="group" (a group may validly be unnamed).
onOpenChange(isOpen: boolean) => void
Callback fired when hover card visibility changes. Called with true when shown and false when hidden.
hasHoverIndication'auto' | boolean · default 'auto'
Shows a dashed underline on the trigger element.
isDefaultOpenboolean
Whether the hover card should be shown on mount. Still dismissible.
isOpenboolean
Controlled open state for the hover card.

Anatomy

Trigger · required

The element that opens the hover card on hover or focus: a button, link, or inline text.

Card · required

The floating overlay with the preview content, anchored to the trigger.

Body · required

The main content area: profile info, link summary, or any rich content.

Actions · optional

Optional buttons inside the card for follow-up actions like Follow or Message.

Theming

Targets

astryx-hover-card
astryx-hovercard

Deprecated; use hover-card.

Variables

--_hovercard-radius · private

Border radius of the hover card

Default: var(--radius-container)

Derived properties

borderRadius

Uses --_hovercard-radius.