# Popover

> A small plate that opens over the page with more about something, and closes when you click away. Card's grey, with an edge and the floating shadow.

| | |
|---|---|
| Kind | component |
| Contract | `review` · [popover.contract.yaml](https://github.com/Runceanu/rost/blob/master/contracts/popover.contract.yaml) |
| Guidance | `proposed` |
| Source | [Figma 738:48](https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=738-48) · read 2026-11-16 · frozen 2026-11-16 |
| Implemented in | nowhere yet |

## Install

It lands in `src/rost/popover/`, with what it needs and its contract:

```sh
npx github:Runceanu/rost add popover
```

Then import `src/rost/fonts.css` and `src/rost/tokens.css` once, at the root of the app. More on this in [Install](https://rost.build/docs/install.md).

## Props

| Prop | Type | Values | Default |
|---|---|---|---|
| `id` | string |  |  |
| `children` | slot |  |  |
| `fit` | boolean |  | `false` |

## Anatomy

- `root`: The browser's popover (`popover="auto"`), with its own look taken away. The browser shows it, hides it and closes it on Esc or a click outside. Where it sits is the page's job.
- `panel`: The plate: 16px inside, as wide as what it holds up to 280px.

## When to use

- **More about something.** How a figure was worked out, the details of a payment, a few settings for one column.

## When not to use

- **A word of explanation.** A label for an icon or a few words on hover. That's **Tooltip**.
- **Something that has to be answered.** If the page should wait for it, that's **Dialog**.
- **Actions.** A list of things to do. That's **Menu**.

## Behaviour

It's the browser's popover: a button with `popovertarget` opens and closes it, Esc and a click outside close it, and only one is open at a time. It adds no type of its own, like Card. It opens under its button, lined up with its start, and moves above it or the other way along when it doesn't fit: CSS anchor positioning, with the button as the anchor. A browser without anchor positioning puts it at the top left of the window, so check the browsers your app supports.

## Accessibility

- **Element**: A `<div popover>`, opened by a `<button popovertarget>`. The browser links the two for screen readers.
- **Name**: Give it an `aria-label` or a heading inside when it's more than a sentence.
- **Keyboard**: Enter or Space on its button opens it. Esc closes it and puts focus back on the button.
- **Colour**: Text inside keeps the page's tokens and their contrast on the #171717 plate.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `popover/background` | `#171717` |
| `popover/edge` | `#3a3a3a` |
| `shadow/floating` | `0px 16px 24px 0px rgba(0, 0, 0, 0.16)` |
| `spacing/gap/medium` | `16px` |
| `spacing/gap/none` | `0px` |
| `spacing/gap/small` | `8px` |
| `spacing/outline/small` | `1px` |
| `spacing/radius/large` | `16px` |

## No token, on purpose

| Part | Property | Value | Why |
|---|---|---|---|
| `panel` | `outline-offset` | `calc(-1 * var(--spacing-outline-small))` | Composed from a token: the edge sits inside the plate. |

See it live, with every value of every variant: [rost.build/components/popover/](https://rost.build/components/popover/)
