# SearchField

> Search above a list: a 40px field with the search icon, Input's colours and focus ring, and a clear button once there's something in it.

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

## Install

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

```sh
npx github:Runceanu/rost add search-field
```

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 |
|---|---|---|---|
| `label` | string |  |  |
| `placeholder` | string |  | `Search` |
| `value` | string |  |  |
| `filled` | boolean |  | `false` |

## States

`Default` · `Hover` · `Focus` · `Disabled` · `ClearFocus`

## Anatomy

- `root`: The box: 40px tall, 12px in at the sides, Input's 12px corners, with the edge drawn inside. A press anywhere puts the caret in the field.
- `icon`: Rost's search icon, 20px, in Input's icon colour.
- `input`: The real `<input type="search">`, filling the rest of the box, its own look taken away. Paragraph type.
- `input-placeholder`: What the empty field says, in Input's label grey.
- `clear` (optional): A 24px round button with Input's clear glyph, on the right when there's something typed. It empties the field and puts the focus back in it.
- `clear-glyph`: Input's clear glyph, 16px, in the value's colour.
- `focus-ring`: Input's ring, 4px outside the box.

## When to use

- **Narrowing a list.** Above a list or a table: invoices by client, the docs by title. The list narrows as you type.

## When not to use

- **Picking one value.** When the answer is one item for a form, that's a **Combobox**.
- **A whole-app search.** Jumping anywhere from the keyboard is **Command**.

## Behaviour

It's a field: what to do with what's typed is the app's, usually narrowing the list under it as you type. The clear button shows once there's something typed, empties it and puts the focus back. Esc empties it too, the browser's way.

## Accessibility

- **Element**: A real `<input type="search">` inside a `role="search"` box, so it's found as a search landmark.
- **Name**: `label`, as `aria-label` on the input. The clear button says Clear search.
- **Keyboard**: Tab reaches the field, then the clear button when it shows. Esc empties the field.
- **Focus**: `focus-ring` around the box, on `:focus-visible`.
- **Colour**: Input's: the edge is 4.3:1 on the dark page, the placeholder 7:1.

## Content

A placeholder that says what's searched, when Search alone isn't enough: Search invoices.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `font-family/base` | `'General Sans Variable'` |
| `opacity/soft` | `0.16` |
| `search-field/background` | `#060805` |
| `search-field/disabled/background` | `#171717` |
| `search-field/disabled/edge` | `#3a3a3a` |
| `search-field/disabled/icon` | `#b6ffda` |
| `search-field/disabled/value` | `#555555` |
| `search-field/edge` | `#747573` |
| `search-field/focus-ring` | `#00d669` |
| `search-field/hover/background` | `#171717` |
| `search-field/hover/edge` | `#999999` |
| `search-field/hover/icon` | `#00b450` |
| `search-field/icon` | `#00d669` |
| `search-field/placeholder` | `#999999` |
| `search-field/value` | `#c2c7c3` |
| `spacing/gap/small` | `8px` |
| `spacing/gap/small-medium` | `12px` |
| `spacing/outline/medium` | `2px` |
| `spacing/outline/small` | `1px` |
| `spacing/radius/full` | `10000px` |
| `spacing/radius/large` | `16px` |
| `spacing/radius/medium` | `12px` |
| `spacing/size/2xsmall` | `16px` |
| `spacing/size/medium` | `40px` |
| `spacing/size/small` | `24px` |
| `spacing/size/xsmall` | `20px` |
| `typography/paragraph/font-size` | `14px` |
| `typography/paragraph/font-weight/regular` | `400` |
| `typography/paragraph/letter-spacing` | `0px` |
| `typography/paragraph/line-height` | `20px` |

## 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 the box. |
| `icon` | `mask` | `url(./icon-search.svg) center / contain no-repeat` | The icon file itself. |
| `clear-glyph` | `mask` | `url(./icon-clear.svg) center / contain no-repeat` | The icon file itself. |
| `focus-ring` | `inset` | `calc(-1 * var(--spacing-gap-2xsmall))` | Composed from a token: the ring sits spacing/gap/2xsmall outside the box. |
| `clear` | `outline` | `var(--spacing-outline-medium) solid var(--search-field-focus-ring)` | Composed from tokens: a 2px ring in search-field/focus-ring. |

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