This page as markdown: /context-card.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

ContextCard

Status: stable

Hover/focus-triggered rich preview card over Base UI PreviewCard. Reveals contextual content (a profile, a project summary) from an inline anchor; 20rem-wide surface with delayed open and collision-aware positioning.

Keywords: context card, rich tooltip, hover card, preview

Usage

Use ContextCard to show richer contextual content near a trigger without taking users out of flow.

Best practices

Anatomy

Part Required Description
ContextCardTrigger yes The element that anchors the card.
ContextCardContent yes The contextual surface shown near the trigger.
ContextCardArrow no An optional arrow connecting card and trigger.

Subcomponents

Name Type Description
ContextCardTrigger Base UI Trigger props + render + delay | closeDelay The inline anchor (renders an ). Use render={} to compose with a link. delay defaults to 600ms, closeDelay to 300ms.
ContextCardContent Base UI Popup props + side | align | sideOffset + className Portals + positions + paints the popup; surface is a fixed 20rem-wide card. side is which side of the trigger to render against (auto-flips on collision), align the alignment along it, sideOffset the gap in px. Defaults to side="bottom", align="center", sideOffset=8.
ContextCardArrow Base UI Arrow props + className Optional pointer connecting the popup to its trigger. Place inside ContextCardContent.

Props

Name Type Default Description
ContextCard (Root) Base UI PreviewCard.Root props (open, defaultOpen, onOpenChange) — Groups the trigger and content. Uncontrolled by default; opens on hover/focus of the trigger.

Tokens used

popover, popover-foreground, border, muted-foreground, accent

Accessibility

Related

  • Components: Popover, Tooltip

Examples

Profile preview

import { Avatar, ContextCard, ContextCardContent, ContextCardTrigger, Entity } from "@sableui/react"

<ContextCard><ContextCardTrigger render={<a href='/u/ada' className='text-title-sm underline-offset-2 hover:underline'>@ada</a>} /><ContextCardContent><Entity className='[--entity-px:0] [--entity-py:0]' leading={<Avatar fallback='AL' size='lg' />} title='Ada Lovelace' subtitle='@ada' /><p className='mt-3 text-body-sm text-muted-foreground'>Product designer. Building tools for small teams.</p></ContextCardContent></ContextCard>

With stat row

import { Avatar, ContextCard, ContextCardContent, ContextCardTrigger, Entity } from "@sableui/react"

<ContextCard><ContextCardTrigger render={<a href='/u/nyx' className='text-title-sm underline-offset-2 hover:underline'>@nyx</a>} /><ContextCardContent><Entity className='[--entity-px:0] [--entity-py:0]' leading={<Avatar fallback='NY' size='lg' />} title='Nyx' subtitle='@nyx' /><div className='@container mt-4 border-t border-border pt-3'><dl className='sable-list-dl sable-list-dl-2'><dt>Posts</dt><dd>128</dd><dt>Followers</dt><dd>4.2k</dd></dl></div></ContextCardContent></ContextCard>