# Hover card

A preview card that opens when the pointer rests on its trigger or the trigger gets keyboard focus.

- Family: overlay
- Import: `import { HoverCard } from "@senvenli/react/overlay";`
- Page: https://design.senvenli.com/docs/components/hover-card
- JSON: https://design.senvenli.com/docs/components/hover-card.json

## Example: A person behind a link

Rest the pointer on the name, or tab to it.

```tsx
import { Link } from "@senvenli/react/action";
import { Avatar, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
import { HoverCard } from "@senvenli/react/overlay";

export default function Example() {
  return (
    <Text>
      Assigned to{" "}
      <HoverCard trigger={<Link href="#sofia">Sofia Marin</Link>}>
        <Stack direction="horizontal" space="space-150" align="start">
          <Avatar name="Sofia Marin" src="/avatars/05.webp" />
          <Stack space="space-025">
            <Text weight="medium">Sofia Marin</Text>
            <Text size="body-small" tone="subtle">Operations · Lisbon</Text>
          </Stack>
        </Stack>
      </HoverCard>
    </Text>
  );
}
```

## Guidelines

### When to use it

- A preview of a person or a record behind a link.

### Use something else when

- [tooltip](https://design.senvenli.com/docs/components/tooltip.md): A few words about a control.
- [popover](https://design.senvenli.com/docs/components/popover.md): Content people open on purpose with a click.

### Do and avoid

- Supplementary only: the trigger must make sense without the card.

## Accessibility

Built in:

- Opens after a delay on hover or focus, stays while the pointer is on it, closes with Esc.

You provide:

- A trigger that is a link (or focusable) to the full page.

## API reference

### HoverCard

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| trigger | `ReactElement<unknown, string \| JSXElementConstructor<any>>` |  | yes | A link (or a focusable element) whose preview the card shows: a person's name, a record reference. |
| children | `React.ReactNode` |  | yes | The preview: an avatar and a line about the person, a record's key fields. Supplementary, never essential. |
| openDelay | `number` | `500` | no | Before it opens (ms); default 500, so moving across the page does not flash cards. |
| closeDelay | `number` | `200` | no | Before it closes after the pointer leaves (ms); default 200, enough to reach the card. |
| placement | `Placement` | `"bottom"` | no |  |

### Tokens it reads

`--ds-background-neutral-bold`, `--ds-background-neutral-pressed`, `--ds-background-neutral-subtle-hovered`, `--ds-blanket`, `--ds-border`, `--ds-border-focused`, `--ds-easing-enter`, `--ds-easing-exit`, `--ds-icon-danger`, `--ds-icon-subtle`, `--ds-radius-large`, `--ds-radius-small`, `--ds-radius-xlarge`, `--ds-shadow-overlay`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-space-300`, `--ds-surface-overlay`, `--ds-text`, `--ds-text-danger`, `--ds-text-disabled`, `--ds-text-inverse`, `--ds-text-subtle`, `--ds-text-subtlest`, `--font-ds-mono`

## Related

- [tooltip](https://design.senvenli.com/docs/components/tooltip.md)
- [popover](https://design.senvenli.com/docs/components/popover.md)
