# Dialog

> A question or a short task that stops everything else until it's answered. A grey plate over the page with a title, a few words and its buttons.

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

## Install

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

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

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 |
|---|---|---|---|
| `open` | boolean |  | `false` |
| `title` | slot |  |  |
| `children` | slot |  |  |
| `actions` | slot |  |  |

## Anatomy

- `root`: The browser's `<dialog>`, with its own look taken away. The browser shows and hides it, and centres it, so the plate is a part inside it.
- `backdrop`: The layer the browser puts between the dialog and the page. The page's own colour at 72%, so the page stays in view but steps back.
- `panel`: The plate: the dialog's fill, a 1px edge and the floating shadow. It holds the title, the words and the buttons in a column, 16px apart.
- `title`: An `<h2>` in title type, medium weight.
- `body`: Paragraph type, a step quieter than the title.
- `actions`: The Buttons, in a row on the right, 8px apart. The main one goes last, where the eye ends up.

## When to use

- **Before something you can't undo.** Deleting an invoice, closing a year. Say what will happen in the title, and put it on the main button too.
- **A short task.** Two or three fields that belong to the screen behind, like renaming a client.

## When not to use

- **News.** Telling someone something happened. That's **Toast**: it doesn't stop them.
- **More detail.** Extra detail next to something. That's **Popover**, or **Disclosure** in the page.
- **Long forms.** Anything that scrolls. Give it a page.

## Behaviour

It opens as a modal: focus moves into it, the page behind can't be reached, and Esc closes it. That's the browser's `<dialog>` doing the work, not mine. The plate is Card's grey with an edge and the floating shadow. Behind it, the page dims to 72% of its own colour: the contract styles the browser's `::backdrop` as a part of its own.

## Accessibility

- **Element**: `<dialog>` opened with `showModal()`, labelled by its title (`aria-labelledby`).
- **Name**: The title.
- **Keyboard**: Focus starts on the first thing you can press in it and stays inside until it closes. Esc closes it. Put the safe choice first, so a stray Enter doesn't delete anything.
- **Focus**: When it closes, focus goes back to what opened it. The browser does that too.
- **Colour**: The title is 14:1 and the words 11:1 on the plate, in dark.

## Content

The title asks the question ("Delete this invoice?"). The buttons answer it with verbs ("Keep it", "Delete"), never "Yes" and "No".

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `dialog/backdrop` | `#060805` |
| `dialog/background` | `#171717` |
| `dialog/body` | `#d3d9d5` |
| `dialog/edge` | `#3a3a3a` |
| `dialog/title` | `#ededed` |
| `font-family/base` | `'General Sans Variable'` |
| `opacity/hard` | `0.72` |
| `shadow/floating` | `0px 16px 24px 0px rgba(0, 0, 0, 0.16)` |
| `spacing/gap/large` | `24px` |
| `spacing/gap/medium` | `16px` |
| `spacing/gap/none` | `0px` |
| `spacing/gap/small` | `8px` |
| `spacing/outline/small` | `1px` |
| `spacing/radius/xlarge` | `24px` |
| `typography/paragraph/font-size` | `14px` |
| `typography/paragraph/font-weight/regular` | `400` |
| `typography/paragraph/letter-spacing` | `0px` |
| `typography/paragraph/line-height` | `20px` |
| `typography/title/font-size` | `24px` |
| `typography/title/font-weight/medium` | `500` |
| `typography/title/letter-spacing` | `0px` |
| `typography/title/line-height` | `32px` |

## 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/dialog/](https://rost.build/components/dialog/)
