<!-- index: /slotted/llms.txt -->
# hover-card

`data-ui="hover-card"` · Preview card that opens on hover or focus.

## Import

```tsx
import { HoverCard, HoverCardTrigger, HoverCardContent, HoverCardDefaultsProvider } from '@slotted/react/hover-card';
import { PopoverBody, PopoverTitle, PopoverFooter } from '@slotted/react/popover';
```

## Minimal example

Example

```tsx
import { Avatar } from '@slotted/react/avatar';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import { Inline } from '@slotted/react/inline';
import { PopoverBody } from '@slotted/react/popover';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

export default function HoverCardBasic() {
  return (
    <Text>
      The pricing table is ready for review. Ask{' '}
      <HoverCard>
        <HoverCardTrigger href="/people/nancy.davolio">@nancy.davolio</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Inline align="center" gap={3}>
              <Avatar name="Nancy Davolio" />
              <Stack gap={1}>
                <Text weight="semibold">Nancy Davolio</Text>
                <Text size="sm" tone="muted">
                  Sales Representative, Seattle
                </Text>
              </Stack>
            </Inline>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>{' '}
      about the carrier rates.
    </Text>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | a, or the element render returns | yes |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `open` | `boolean \| undefined` | — | HoverCard | Whether the card shows. Present at all puts the card in controlled mode: it asks and waits. |
| `defaultOpen` | `boolean` | — | HoverCard | The value an uncontrolled card starts from, read once. |
| `onOpenChange` | `(open, request) => void` | — | HoverCard | Asked before the card opens or closes, with the reason and the originating event, and refusable. |
| `openDelay` | `number` | 600 | HoverCard | Milliseconds the pointer rests on the trigger before the card opens. Focus never waits. |
| `closeDelay` | `number` | 300 | HoverCard | Milliseconds after the pointer has left trigger and card before it closes; a pointer on its way to the card is not counted as gone. |
| `navigable` | `boolean` | false | HoverCard | Whether the card holds controls a keyboard reader can reach. On, the panel is a dialog, the link announces it and Tab enters it; off, the panel is presentation. |
| `disabled` | `boolean` | false | HoverCard | The card never opens. The link keeps working, and carries no disabled state. |
| `sideOffset` | `number` | 4 | HoverCard | The popover’s own axis, with the hover card’s default: the halo the open mark draws plus the same again of air, so the arrow’s tip stands off the word. |
| `side, align, size, width, arrow, mount, …` | `PopoverProps` | — | HoverCard | Every prop of Popover except autoFocus, which the hover card forces off, reaches the popover it renders. |
| `render` | `(props) => ReactNode` | — | HoverCardTrigger | Renders the consumer's own element as the trigger — a Link, an avatar button — with the identity, the state and the listeners on it. |
| `HoverCardDefaultsProvider` | `component` | — | Application | Sets openDelay, closeDelay, navigable and disabled once for a subtree. A card that states one itself still wins. The panel reads PopoverDefaultsProvider. |
| `PopoverHeader, PopoverTitle, PopoverBody, PopoverFooter, PopoverClose, …` | `components` | — | Inside HoverCardContent | The card is the popover family unchanged, and nothing is re-exported: its title names a navigable card, its Close is the touch reader’s Escape. |
| `HoverCardContent` | `component` | — | Inside a HoverCard | The popover’s layer and panel in one, with the hover card’s pointer handlers on the layer and the panel’s role decided by navigable. Its props reach the panel; the arrow is rendered under the popover’s arrow axis. |
| `ref` | `prop` | — | HoverCard | A PopoverHandle carrying open(), close() and reposition(). |
| `native props` | `attributes` | — | HoverCardTrigger | Anything an anchor takes — href, rel, target — reaches the link, and a consumer's own onPointerEnter or onFocus runs before the hover card's own; preventDefault from it stops the hover card's handler. |

## Events

| Name | Payload | When |
| --- | --- | --- |
| `onOpenChange` | `(open: boolean, request: HoverCardChangeRequest)` | Before the card opens or closes. The request carries pointer (hover in, hover out, a tap), keyboard (focus arriving, a focus guard), escape, outsidePress, blur (focus leaving the trigger), dismiss (the Close part) or programmatic, the originating event, and cancel(). |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `navigable` | `true`, `false` | `false` |
| `disabled` | `true`, `false` | `false` |

## Rules

- The platform supplies the link: it is a native anchor, so Enter follows it, a middle click opens it in a tab and a screen reader hears a link. The card never takes focus when it opens — autoFocus is forced off on the popover it holds — so the reader’s focus stays on the word under the pointer.
- The hover card answers WCAG 2.2 SC 1.4.13 item by item: the card is dismissible with Escape and no pointer movement, hoverable because the pointer may move onto it and the grace area keeps it open on the way, and persistent because it stays until hover and focus have left both link and card.
- A popup that assistive technology cannot reach is not announced: a card the keyboard cannot enter is role="presentation", and the link says nothing about it. A navigable card is the APG’s non-modal dialog, named by its title, with aria-haspopup="dialog", aria-expanded and aria-controls on the link, and Tab from the link enters it.
- Focus that the hover card itself puts back on the link — after Escape inside the card, after a focus guard — does not reopen the card; the link holds the reopening back until focus has left it once. Without that rule a guard would close the card, focus the link, and open the card again.

## Tokens

`--slotted-border-width-thick`, `--slotted-duration-short`, `--slotted-easing-standard`, `--slotted-focus-ring-color`, `--slotted-focus-ring-offset`, `--slotted-focus-ring-width`, `--slotted-highlight-tint-opacity`, `--slotted-hover-card-color`, `--slotted-hover-card-halo`, `--slotted-hover-card-radius`, `--slotted-hover-card-tint`, `--slotted-hover-card-underline-color`, `--slotted-radius-xs`, `--slotted-space-1`, `--slotted-tone-accent-text`

## Examples

### Playground

Rest the pointer on the mention, or Tab to it: the card opens after the delay under the pointer and at once under focus. The controls under the canvas move both delays and make the card navigable.

Excerpt — not a complete module

```tsx
<HoverCard>
  <HoverCardTrigger href="/people/ana">@ana.souza</HoverCardTrigger>
  <HoverCardContent>
    <PopoverBody>…</PopoverBody>
  </HoverCardContent>
</HoverCard>;
```

### A person

The card a review thread shows for a handle: avatar, name, team and what they own, under the word it is about. While it shows, the word carries a tint and a halo that grow the inline box without moving the line — the sentence under it has not shifted.

Excerpt — not a complete module

```tsx
<HoverCard defaultOpen>
  <HoverCardTrigger href="/people/ana">@ana.souza</HoverCardTrigger>
  <HoverCardContent>
    <PopoverBody>
      <Avatar name="Ana Souza" />…
    </PopoverBody>
  </HoverCardContent>
</HoverCard>;
```

### A document

The card a link to a spec shows: its title, who touched it last and its first lines. The trigger stays a link — Enter follows it, a middle click opens it in a tab — and the card adds nothing the destination does not have.

Example

```tsx
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import {
  PopoverBody,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
} from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

export default function HoverCardLinkPreview() {
  return (
    <Text>
      Freight for October follows the{' '}
      <HoverCard>
        <HoverCardTrigger href="/documents/q4-carrier-rate-card">
          Q4 carrier rate card
        </HoverCardTrigger>
        <HoverCardContent>
          <PopoverHeader>
            <PopoverTitle>Q4 carrier rate card</PopoverTitle>
            <PopoverDescription>Spreadsheet, updated 2 hours ago</PopoverDescription>
          </PopoverHeader>
          <PopoverBody>
            <Text size="sm">
              Freight rates by carrier and zone for October through December, with the fuel
              surcharge from Oct 1.
            </Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>
      , which Federal Shipping has already signed.
    </Text>
  );
}
```

### Navigable

The card holds a control, so the page says so with navigable: the panel becomes a dialog named by its title, the link announces the popup, and Tab from the open link enters the card. Past its last control a focus guard closes it and puts focus back on the link, which does not reopen.

Example

```tsx
import { Button } from '@slotted/react/button';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import {
  PopoverBody,
  PopoverDescription,
  PopoverFooter,
  PopoverHeader,
  PopoverTitle,
} from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

export default function HoverCardNavigable() {
  return (
    <Text>
      The credit limit for Around the Horn is waiting on{' '}
      <HoverCard navigable>
        <HoverCardTrigger href="/people/andrew.fuller">@andrew.fuller</HoverCardTrigger>
        <HoverCardContent>
          <PopoverHeader>
            <PopoverTitle>Andrew Fuller</PopoverTitle>
            <PopoverDescription>Vice President, Sales</PopoverDescription>
          </PopoverHeader>
          <PopoverBody>
            <Text size="sm">Approves credit limits above $25,000.</Text>
          </PopoverBody>
          <PopoverFooter>
            <Button size="sm">Send message</Button>
          </PopoverFooter>
        </HoverCardContent>
      </HoverCard>
      .
    </Text>
  );
}
```

### The delays

Two of the same card: the left opens after the default 600 ms and closes 300 ms after the pointer has left; the right answers at once and holds for a second, for a page where the preview is the point. Focus never waits on either.

Excerpt — not a complete module

```tsx
<HoverCard openDelay={0} closeDelay={1000}>
  …
</HoverCard>;

<HoverCardDefaultsProvider openDelay={400}>
  <App />
</HoverCardDefaultsProvider>;
```

### One card, many mentions

A thread with four handles and one HoverCard around all of them. The mention the pointer rests on registers itself as the anchor, and the request carries the event whose target sits inside the mention that names the person, so the card fills from one state instead of mounting four.

Example

```tsx
import { useState } from 'react';

import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import type { HoverCardChangeRequest } from '@slotted/react/hover-card';
import {
  PopoverBody,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
} from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

interface Person {
  handle: string;
  name: string;
  role: string;
}

const nancy: Person = {
  handle: 'nancy.davolio',
  name: 'Nancy Davolio',
  role: 'Sales Representative, Seattle',
};
const andrew: Person = {
  handle: 'andrew.fuller',
  name: 'Andrew Fuller',
  role: 'Vice President, Sales',
};
const janet: Person = {
  handle: 'janet.leverling',
  name: 'Janet Leverling',
  role: 'Sales Representative, Kirkland',
};
const people = [nancy, andrew, janet];

export default function HoverCardShared() {
  const [person, setPerson] = useState(nancy);

  function handleOpenChange(open: boolean, request: HoverCardChangeRequest) {
    const target = request.source instanceof Event ? request.source.target : null;
    const trigger = target instanceof Element ? target.closest<HTMLElement>('[data-handle]') : null;
    if (!open || trigger === null) return;

    const next = people.find((candidate) => candidate.handle === trigger.dataset['handle']);
    if (next !== undefined) setPerson(next);
  }

  return (
    <HoverCard onOpenChange={handleOpenChange}>
      <Text>
        The pricing table was drafted by{' '}
        <HoverCardTrigger data-handle={nancy.handle} href="/people/nancy.davolio">
          @nancy.davolio
        </HoverCardTrigger>
        , approved by{' '}
        <HoverCardTrigger data-handle={andrew.handle} href="/people/andrew.fuller">
          @andrew.fuller
        </HoverCardTrigger>{' '}
        and handed to{' '}
        <HoverCardTrigger data-handle={janet.handle} href="/people/janet.leverling">
          @janet.leverling
        </HoverCardTrigger>{' '}
        for the carrier terms.
      </Text>
      <HoverCardContent>
        <PopoverHeader>
          <PopoverTitle>{person.name}</PopoverTitle>
          <PopoverDescription>{person.role}</PopoverDescription>
        </PopoverHeader>
        <PopoverBody>
          <Text size="sm">@{person.handle}</Text>
        </PopoverBody>
      </HoverCardContent>
    </HoverCard>
  );
}
```

### On touch

There is no hover on a touch screen: the first tap on the mention opens the card instead of following the link, and a tap on the open mention follows it. The cost is one extra tap to navigate; the alternative is a preview no touch reader ever sees.

Excerpt — not a complete module

```tsx
<HoverCard>
  <HoverCardTrigger href="/people/ana">@ana.souza</HoverCardTrigger>
  <HoverCardContent>…</HoverCardContent>
</HoverCard>;
```

### On another family’s link

The trigger rendered onto Link: the link keeps its own paint and its identity, and takes only the state and the listeners from the hover card. The Close part inside the card is the popover’s, and it is what a touch reader has in place of Escape.

Excerpt — not a complete module

```tsx
<HoverCard>
  <HoverCardTrigger href="/people/ana" render={(props) => <Link {...props} variant="neutral" />}>
    Ana Souza
  </HoverCardTrigger>
  <HoverCardContent>
    <PopoverHeader>
      <PopoverTitle>Ana Souza</PopoverTitle>
      <PopoverClose />
    </PopoverHeader>
  </HoverCardContent>
</HoverCard>;
```

### From the keyboard

Tab onto the mention: the card opens in the same task, without the pointer's delay. Escape closes it and leaves focus where it is, and the mention does not reopen until focus has left it once. Tab on moves focus down the page and closes the card with the reason blur.

Excerpt — not a complete module

```tsx
<HoverCard onOpenChange={(open, request) => log(request.reason)}>
  <HoverCardTrigger href="/people/ana">@ana.souza</HoverCardTrigger>
  <HoverCardContent>…</HoverCardContent>
</HoverCard>;
```

### controlled.tsx

Example

```tsx
import { useState } from 'react';

import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import type { HoverCardChangeRequest } from '@slotted/react/hover-card';
import {
  PopoverBody,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
} from '@slotted/react/popover';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

export default function HoverCardControlled() {
  const [open, setOpen] = useState(false);
  const [reason, setReason] = useState('none');

  function handleOpenChange(next: boolean, request: HoverCardChangeRequest) {
    setOpen(next);
    setReason(request.reason);
  }

  return (
    <Stack gap={3}>
      <Text>
        Stock for order 10251 ships from the{' '}
        <HoverCard open={open} onOpenChange={handleOpenChange}>
          <HoverCardTrigger href="/warehouses/seattle">Seattle warehouse</HoverCardTrigger>
          <HoverCardContent>
            <PopoverHeader>
              <PopoverTitle>Seattle warehouse</PopoverTitle>
              <PopoverDescription>400 Pine Street, Dock 3</PopoverDescription>
            </PopoverHeader>
            <PopoverBody>
              <Text size="sm">Pickups close at 4:30 PM, Monday to Friday.</Text>
            </PopoverBody>
          </HoverCardContent>
        </HoverCard>
        .
      </Text>
      <Text size="sm" tone="muted">
        Card {open ? 'open' : 'closed'}. Last request: {reason}.
      </Text>
    </Stack>
  );
}
```

### defaults.tsx

Example

```tsx
import {
  HoverCard,
  HoverCardContent,
  HoverCardDefaultsProvider,
  HoverCardTrigger,
} from '@slotted/react/hover-card';
import { PopoverBody } from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

export default function HoverCardDefaults() {
  return (
    <HoverCardDefaultsProvider openDelay={200} closeDelay={200}>
      <Text>
        Escalate to{' '}
        <HoverCard>
          <HoverCardTrigger href="/people/steven.buchanan">@steven.buchanan</HoverCardTrigger>
          <HoverCardContent>
            <PopoverBody>
              <Text size="sm">Steven Buchanan, Sales Manager, London.</Text>
            </PopoverBody>
          </HoverCardContent>
        </HoverCard>{' '}
        or, for returns, to{' '}
        <HoverCard closeDelay={1000}>
          <HoverCardTrigger href="/people/margaret.peacock">@margaret.peacock</HoverCardTrigger>
          <HoverCardContent>
            <PopoverBody>
              <Text size="sm">Margaret Peacock, Sales Representative, Redmond.</Text>
            </PopoverBody>
          </HoverCardContent>
        </HoverCard>
        .
      </Text>
    </HoverCardDefaultsProvider>
  );
}
```

### delays.tsx

Example

```tsx
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import { PopoverBody } from '@slotted/react/popover';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';

export default function HoverCardDelays() {
  return (
    <Stack gap={4}>
      <Text>
        Default delays, 600 ms to open and 300 ms to close:{' '}
        <HoverCard>
          <HoverCardTrigger href="/orders/10248">Order 10248</HoverCardTrigger>
          <HoverCardContent>
            <PopoverBody>
              <Text size="sm">Vins et alcools Chevalier, $440.00, shipped Jul 16.</Text>
            </PopoverBody>
          </HoverCardContent>
        </HoverCard>
      </Text>
      <Text>
        Immediate open, closes after 1 second:{' '}
        <HoverCard openDelay={0} closeDelay={1000}>
          <HoverCardTrigger href="/orders/10249">Order 10249</HoverCardTrigger>
          <HoverCardContent>
            <PopoverBody>
              <Text size="sm">Toms Spezialitäten, $1,863.40, shipped Jul 10.</Text>
            </PopoverBody>
          </HoverCardContent>
        </HoverCard>
      </Text>
    </Stack>
  );
}
```

### disabled.tsx

Example

```tsx
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import { PopoverBody } from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

export default function HoverCardDisabled() {
  return (
    <Text>
      Territory handoff from{' '}
      <HoverCard>
        <HoverCardTrigger href="/people/nancy.davolio">@nancy.davolio</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Text size="sm">Nancy Davolio, Sales Representative, Seattle.</Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>{' '}
      to{' '}
      <HoverCard disabled>
        <HoverCardTrigger href="/people/robert.king">@robert.king</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Text size="sm">Robert King, Sales Representative, London.</Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>
      , whose profile is archived.
    </Text>
  );
}
```

### placement.tsx

Example

```tsx
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@slotted/react/hover-card';
import { PopoverBody } from '@slotted/react/popover';
import { Text } from '@slotted/react/typography';

export default function HoverCardPlacement() {
  return (
    <Text>
      Reorder{' '}
      <HoverCard side="top" align="center">
        <HoverCardTrigger href="/products/1001">Chai</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Text size="sm">NW-1001, 39 units on hand.</Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>
      ,{' '}
      <HoverCard>
        <HoverCardTrigger href="/products/1002">Chang</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Text size="sm">NW-1002, 17 units on hand.</Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>{' '}
      and{' '}
      <HoverCard side="inline-end" align="center">
        <HoverCardTrigger href="/products/1003">Aniseed Syrup</HoverCardTrigger>
        <HoverCardContent>
          <PopoverBody>
            <Text size="sm">NW-1003, 13 units on hand.</Text>
          </PopoverBody>
        </HoverCardContent>
      </HoverCard>{' '}
      before Friday.
    </Text>
  );
}
```
