Examples

Person mention

Preview

Assigned to @ada on Tuesday.

Example.tsx
import { HoverCard, Link, Stack, Text } from '@reactloom/ui';

export default function Example() {
  return (
    <p style={{ margin: 0 }}>
      Assigned to{' '}
      <HoverCard
        content={
          <Stack gap="1">
            <Text weight="semibold">Ada Lovelace</Text>
            <Text size="sm" tone="muted">
              Staff engineer · London · Usually replies within an hour
            </Text>
            <Link href="#profile">View profile</Link>
          </Stack>
        }
      >
        <Link href="#ada">@ada</Link>
      </HoverCard>{' '}
      on Tuesday.
    </p>
  );
}

Linked record

Preview

Blocked by INC-482.

Example.tsx
import { Badge, HoverCard, HStack, Link, Stack, Text } from '@reactloom/ui';

export default function Example() {
  return (
    <p style={{ margin: 0 }}>
      Blocked by{' '}
      <HoverCard
        size="lg"
        placement="top-start"
        content={
          <Stack gap="2">
            <HStack gap="2" align="center">
              <Text weight="semibold">INC-482 · Payments timing out</Text>
              <Badge tone="danger">Open</Badge>
            </HStack>
            <Text size="sm">Card payments in the EU region fail after 30 seconds. Rollback in progress.</Text>
            <Link href="#incident">Open incident</Link>
          </Stack>
        }
      >
        <Link href="#incident">INC-482</Link>
      </HoverCard>
      .
    </p>
  );
}

API reference

HoverCard props
PropTypeDefault
childrenrequired
The trigger, usually a link.
ReactElement—
contentrequired
Preview content; may contain links.
ReactNode—
placement
OverlayPlacement'bottom-start'
openDelay · closeDelay
In ms.
number500 · 300
open / defaultOpen / onOpenChange
boolean—
size
'sm' | 'md' | 'lg' | 'auto''md'

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-size]sm · md · lg · auto

Theme tokens it reads

--pl-color-bg-surface-raised --pl-color-border-default --pl-color-fg-default --pl-font-size-md --pl-radius-lg --pl-shadow-md

Accessibility

  • Opens on focus as well as hover; Tab from the trigger enters the card and Tab out continues after the trigger.
  • Escape closes it.
  • Touch screens have no hover, so the same information must be where the trigger leads.
Keyboard interactions
KeyAction
TabInto the open card, then on past the trigger
EscapeClose

Usage guidelines

Do

  • Use for previews that save a click.
  • Keep the trigger a real link to the full record.

Don’t

  • Don’t put the only copy of information or an essential action in a hover card.