# Kbd

> A key on the keyboard, written in the text. A small grey cap with the key's name in mono.

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

## Install

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

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

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 |
|---|---|---|---|
| `children` | slot |  |  |

## Anatomy

- `root`: A `<kbd>`. 20px tall, at least as wide, so a single letter is a square.

## When to use

- **Shortcuts.** Telling someone which keys do something: Press ⌘ + K to search.

## When not to use

- **Code.** Something you type, like a command or a value. That's **Code**.

## Behaviour

A cap per key. It doesn't press: it's text.

## Accessibility

- **Element**: `<kbd>`, which screen readers know as keyboard input.
- **Name**: The key's name. Write symbols out in an `aria-label` when they'd be read oddly (⌘ is "Command").
- **Colour**: The key's name is 11:1 on its cap in dark.

## Content

The key as it's printed on the keyboard: Esc, Enter, Tab, ⌘.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `kbd/background` | `#171717` |
| `kbd/edge` | `#3a3a3a` |
| `kbd/label` | `#d3d9d5` |
| `spacing/gap/xsmall` | `6px` |
| `spacing/outline/small` | `1px` |
| `spacing/radius/xsmall` | `4px` |
| `spacing/size/xsmall` | `20px` |
| `typography/label/font-size` | `12px` |
| `typography/label/font-weight/medium` | `500` |
| `typography/label/line-height` | `14px` |

## No token, on purpose

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

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