# ContextMenu

> DropdownMenu's plate, opened where you right-click instead of under a button. For the actions on a row or a card, as a shortcut.

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

## Install

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

```sh
npx github:Runceanu/rost add context-menu
```

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 |  |  |
| `items` | slot |  |  |
| `label` | string |  |  |

## Anatomy

- `root`: The area you right-click. It takes no room of its own.
- `menu`: DropdownMenu's plate, as the browser's popover with `role="menu"`, placed where the pointer was and kept inside the window.

## When to use

- **A shortcut to a row's actions.** Right-clicking an invoice in a list for Duplicate or Delete, when the same actions are also somewhere you can see.

## When not to use

- **The only way to do something.** Nobody knows to right-click, and phones can't. Put the actions in a **DropdownMenu** on the row too.

## Behaviour

A right-click on the area opens the menu where the pointer is, moved in if it would go off the window, with the focus on the first item. The context menu key and Shift+F10 open it at the focused element. Inside it works as DropdownMenu does: Up and Down, Home and End, Enter to act, Esc, Tab or a click outside to close, and the focus goes back to where it was.

## Accessibility

- **Element**: `role="menu"` on the plate, `role="menuitem"` on each item.
- **Name**: `label`.
- **Keyboard**: The context menu key or Shift+F10 on anything focusable inside the area opens it.
- **Colour**: DropdownMenu's: the edge is drawing; the items carry their own contrast.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `context-menu/background` | `#171717` |
| `context-menu/edge` | `#3a3a3a` |
| `shadow/floating` | `0px 16px 24px 0px rgba(0, 0, 0, 0.16)` |
| `spacing/gap/2xsmall` | `4px` |
| `spacing/gap/none` | `0px` |
| `spacing/outline/small` | `1px` |
| `spacing/radius/medium` | `12px` |

## No token, on purpose

| Part | Property | Value | Why |
|---|---|---|---|
| `menu` | `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/dropdown-menu/#context-menu](https://rost.build/components/dropdown-menu/#context-menu)
