component
Combobox
One choice from a long list, found by typing. Select's field you can type in, and the matching options in a list under it.
Try it
Every variant
Default · Not errorDisabled · Not errorDefault · ErrorHover, press or tab to one to see the other 4 states.
import { Combobox } from 'rost/components/combobox/Combobox'
<Combobox
label="Client"
options={clients.map((c) => ({ value: c.id, label: c.name }))}
value={clientId}
onValueChange={setClientId}
/> src/components/combobox/Combobox.tsx
import { useEffect, useId, useRef, useState, type CSSProperties, type KeyboardEvent, type ReactNode } from 'react'
import { ComboboxOption } from '../combobox-option/ComboboxOption'
import './combobox.css'
export interface ComboboxItem {
readonly value: string
readonly label: string
}
export interface ComboboxProps {
/** The field's name, small at the top. */
readonly label: ReactNode
/** The options, in order. */
readonly options: readonly ComboboxItem[]
/** The picked option's value. */
readonly value?: string | null
readonly onValueChange?: (value: string) => void
/** What the empty field says once it has the focus. */
readonly placeholder?: string
/** What the list says when nothing matches. */
readonly empty?: string
/** One line under the field: help, or what to fix. */
readonly supportive?: ReactNode
/** Select's red. */
readonly error?: boolean
readonly disabled?: boolean
readonly id?: string
readonly className?: string
}
const b = 'rost-combobox'
/**
* One choice from a long list, found by typing. An `<input role="combobox">`
* over Select's field and a filtered `role="listbox"` under it, the ARIA
* pattern with `aria-activedescendant`. Built from contracts/combobox.contract.yaml.
*/
export function Combobox({ label, options, value = null, onValueChange, placeholder, empty = 'No match', supportive, error = false, disabled = false, id, className }: ComboboxProps) {
const made = useId()
const fieldId = id ?? made
const listId = `${fieldId}-list`
const helpId = `${fieldId}-help`
const anchor = `--rost-combobox-${made.replace(/[^a-zA-Z0-9]/g, '')}`
const list = useRef<HTMLDivElement>(null)
const picked = options.find((o) => o.value === value) ?? null
const [query, setQuery] = useState<string | null>(null)
const [open, setOpen] = useState(false)
const [active, setActive] = useState(0)
const shown = query == null ? options : options.filter((o) => o.label.toLowerCase().includes(query.toLowerCase()))
const optId = (i: number) => `${fieldId}-opt-${i}`
// Keep the highlighted option in view when the list scrolls.
useEffect(() => { if (open) document.getElementById(optId(active))?.scrollIntoView({ block: 'nearest' }) }, [open, active])
const show = (on: boolean) => {
const el = list.current
if (!el) return
if (on && !el.matches(':popover-open')) el.showPopover()
if (!on && el.matches(':popover-open')) el.hidePopover()
setOpen(on)
}
const openAt = (i: number) => { setActive(i); show(true) }
const pick = (o: ComboboxItem) => { onValueChange?.(o.value); setQuery(null); show(false) }
const key = (e: KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'ArrowDown') { e.preventDefault(); if (!open) openAt(Math.max(0, shown.findIndex((o) => o.value === value))); else setActive((a) => Math.min(a + 1, shown.length - 1)) }
else if (e.key === 'ArrowUp') { e.preventDefault(); if (open) setActive((a) => Math.max(a - 1, 0)) }
else if (e.key === 'Enter') { if (open && shown[active]) { e.preventDefault(); pick(shown[active]) } }
else if (e.key === 'Escape') { if (open) { e.preventDefault(); show(false) } else setQuery(null) }
}
return (
<div className={[b, error && `${b}--error`, className].filter(Boolean).join(' ')} style={{ anchorName: anchor } as CSSProperties}>
<span className={`${b}__outline`} aria-hidden="true" />
<input
id={fieldId}
className={`${b}__field`}
role="combobox"
type="text"
autoComplete="off"
disabled={disabled}
placeholder={placeholder}
value={query ?? picked?.label ?? ''}
aria-expanded={open}
aria-controls={listId}
aria-autocomplete="list"
aria-activedescendant={open && shown[active] ? optId(active) : undefined}
aria-invalid={error || undefined}
aria-describedby={supportive != null ? helpId : undefined}
onChange={(e) => { setQuery(e.target.value); openAt(0) }}
onKeyDown={key}
onClick={() => { if (!open) openAt(Math.max(0, shown.findIndex((o) => o.value === value))) }}
onBlur={() => { setQuery(null); show(false) }}
/>
<label className={`${b}__label`} htmlFor={fieldId}>{label}</label>
<span className={`${b}__chevron`} aria-hidden="true" />
{supportive != null && <span id={helpId} className={`${b}__supportive`}>{supportive}</span>}
<span className={`${b}__focus-ring`} aria-hidden="true" />
<div ref={list} id={listId} popover="manual" role="listbox" aria-labelledby={fieldId} className={`${b}__listbox`} style={{ positionAnchor: anchor } as CSSProperties}>
{shown.length ? shown.map((o, i) => (
<ComboboxOption
key={o.value}
id={optId(i)}
selected={o.value === value}
active={i === active}
onMouseDown={(e) => e.preventDefault()}
onMouseEnter={() => setActive(i)}
onClick={() => pick(o)}
>
{o.label}
</ComboboxOption>
)) : <div className={`${b}__empty`}>{empty}</div>}
</div>
</div>
)
}
The source for everything on this page: contracts/combobox.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: combobox
name: Combobox
kind: component
status: review
summary: "One choice from a long list, found by typing. Select's field you can type in, and the matching options in a list under it."
category: inputs
related: [ combobox-option, select, input, dropdown-menu ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "756:58"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=756-58
extractedAt: "2026-11-17"
extractedBy: hand
frozenAt: "2026-11-17"
props:
label: { type: slot, required: true, notes: "The field's name, small at the top, as Select's is." }
options: { type: node, required: true, notes: "`{ value, label }`, in the order to show them." }
value: { type: string, notes: "The picked option's `value`, or nothing." }
placeholder: { type: string, notes: "What the empty field says once it has the focus." }
empty: { type: string, default: No match, notes: "What the list says when nothing matches." }
supportive: { type: slot, notes: "One line under the field: help, or what to fix when `error` is on." }
error: { type: boolean, default: false, notes: "Select's red." }
states: [ Default, Hover, Focus, Disabled ]
stateSelectors:
Focus: ":has(> .rost-combobox__field:focus-visible)"
Disabled: ":has(> .rost-combobox__field:disabled)"
elements:
root:
notes: "A box the size of Input, holding the parts, exactly as Select's. The input covers all of it, so a press anywhere puts the caret in it and opens the list."
styles:
display: { value: block, assert: false }
position: { value: relative, assert: false }
height: { token: spacing/size/large, value: 56px }
width: { value: 208px, notes: "Just the size of the Figma frame, as Input's is. A field is as wide as its form." }
outline:
notes: "The field's fill and its 1px edge, on their own layer, as Input has them."
styles:
position: { value: absolute }
inset: { value: "0" }
border-style: { value: solid }
border-width: { token: spacing/outline/small, value: 1px }
border-radius: { token: spacing/radius/medium, value: 12px }
pointer-events: { value: none, assert: false }
label:
notes: "Select's label: placeholder type, 12px in from the edges. A `<label>` for the input."
styles:
position: { value: absolute }
top: { token: spacing/gap/small-medium, value: 12px }
left: { token: spacing/gap/small-medium, value: 12px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/regular, value: "400" }
font-size: { token: typography/placeholder/font-size, value: 10px }
line-height: { token: typography/placeholder/line-height, value: 12px }
letter-spacing: { token: typography/placeholder/letter-spacing, value: 0px }
pointer-events: { value: none, assert: false }
field:
notes: "An `<input role=\"combobox\">` over the whole box. What you type, or the picked option, sits where Select shows its value."
styles:
box-sizing: { value: border-box, assert: false }
width: { value: 100%, assert: false }
cursor: { value: text, assert: false }
position: { value: absolute }
inset: { value: "0" }
appearance: { value: none, assert: false }
background: { value: transparent, assert: false }
border: { value: none, assert: false }
outline: { value: none, assert: false }
padding-top: { token: spacing/gap/large, value: 24px, notes: "The label's 12px and its 12px line above the value." }
padding-bottom: { token: spacing/gap/small-medium, value: 12px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/size/medium, value: 40px, notes: "Room for the chevron and the 12px after it." }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
chevron:
notes: "Rost's chevron-down, 20px, drawn as a mask in Input's icon colour, 12px from the right edge."
styles:
position: { value: absolute }
top: { token: spacing/gap/medium-large, value: 20px, notes: "Centres the 20px chevron on the value line." }
right: { token: spacing/gap/small-medium, value: 12px }
width: { token: spacing/size/xsmall, value: 20px }
height: { token: spacing/size/xsmall, value: 20px }
mask: { value: url(./icon-chevron.svg) center / contain no-repeat, untokenised: The icon file itself. }
pointer-events: { value: none, assert: false }
supportive:
notes: "Input's help line, 4px under the field. It sits outside the field's box, so it doesn't change the field's height."
styles:
position: { value: absolute }
left: { token: spacing/gap/small-medium, value: 12px }
top: { value: "calc(var(--spacing-size-large) + var(--spacing-gap-2xsmall))", untokenised: "Composed from tokens: the field's height plus spacing/gap/2xsmall." }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/medium, value: "500" }
font-size: { token: typography/placeholder/font-size, value: 10px }
line-height: { token: typography/placeholder/line-height, value: 12px }
letter-spacing: { token: typography/placeholder/letter-spacing, value: 0px }
white-space: { value: nowrap, assert: false }
focus-ring:
notes: Input's ring, 4px outside the field.
styles:
display: { value: none, assert: false }
position: { value: absolute }
inset: { value: "calc(-1 * var(--spacing-gap-2xsmall))", untokenised: "Composed from a token: the ring sits spacing/gap/2xsmall outside the field." }
border-style: { value: solid }
border-width: { token: spacing/outline/medium, value: 2px }
border-radius: { token: spacing/radius/large, value: 16px }
pointer-events: { value: none, assert: false }
listbox:
notes: "`role=\"listbox\"`, a popover under the field, 8px away and at least as wide as it. DropdownMenu's plate: 4px inside, Popover's grey, edge and shadow."
styles:
inset: { value: auto, assert: false }
margin: { token: spacing/gap/none, value: 0px }
margin-block-start: { token: spacing/gap/small, value: 8px }
position-area: { value: block-end span-inline-end, assert: false }
position-try-fallbacks: { value: flip-block, assert: false }
min-width: { value: anchor-size(width), assert: false, notes: "As wide as the field it opens from." }
max-height: { value: 240px, notes: "Six options; more scroll." }
overflow-y: { value: auto, assert: false }
padding: { token: spacing/gap/2xsmall, value: 4px }
border: { value: none, assert: false }
border-radius: { token: spacing/radius/medium, value: 12px }
background: { token: combobox/listbox/background, value: "#171717" }
outline-style: { value: solid, assert: false }
outline-width: { token: spacing/outline/small, value: 1px }
outline-offset: { value: "calc(-1 * var(--spacing-outline-small))", untokenised: "Composed from a token: the edge sits inside the plate." }
outline-color: { token: combobox/listbox/edge, value: "#3a3a3a" }
box-shadow: { token: shadow/floating, value: "0px 16px 24px 0px rgba(0, 0, 0, 0.16)" }
color: { value: inherit, assert: false }
empty:
optional: true
notes: "When nothing matches: one 40px row in paragraph type and the tertiary grey."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
height: { token: spacing/size/medium, value: 40px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: combobox/empty, value: "#999999" }
variants:
- when: { state: Default, error: false }
figmaNode: "756:11"
elements:
outline:
background: { token: select/default/background, value: "#060805" }
border-color: { token: select/default/outline, value: "#747573" }
label:
color: { token: select/default/label, value: "#999999" }
field:
color: { token: select/default/value, value: "#c2c7c3" }
chevron:
background: { token: select/default/chevron, value: "#00d669" }
supportive:
color: { token: select/default/supportive, value: "#999999" }
- when: { state: Hover, error: false }
figmaNode: "756:17"
elements:
outline:
background: { token: select/hover/background, value: "#171717" }
border-color: { token: select/hover/outline, value: "#999999" }
label:
color: { token: select/hover/label, value: "#d3d9d5" }
field:
color: { token: select/hover/value, value: "#d3d9d5" }
chevron:
background: { token: select/hover/chevron, value: "#00b450" }
supportive:
color: { token: select/hover/supportive, value: "#d3d9d5" }
- when: { state: Focus, error: false }
figmaNode: "756:23"
elements:
outline:
background: { token: select/focus/background, value: "#060805" }
border-color: { token: select/focus/outline, value: "#747573" }
label:
color: { token: select/focus/label, value: "#999999" }
field:
color: { token: select/focus/value, value: "#c2c7c3" }
chevron:
background: { token: select/focus/chevron, value: "#00d669" }
supportive:
color: { token: select/focus/supportive, value: "#999999" }
focus-ring:
display: { value: block, assert: false }
border-color: { token: select/focus/focus-ring, value: "#00d669" }
- when: { state: Disabled, error: false }
figmaNode: "756:30"
elements:
outline:
background: { token: select/disabled/background, value: "#171717" }
border-color: { token: select/disabled/outline, value: "#3a3a3a" }
label:
color: { token: select/disabled/label, value: "#555555" }
field:
color: { token: select/disabled/value, value: "#555555" }
chevron:
background: { token: select/disabled/chevron, value: "#b6ffda" }
opacity: { token: opacity/soft, value: "0.16", notes: "As Input's icon does when it's disabled." }
supportive:
color: { token: select/disabled/supportive, value: "#555555" }
- when: { state: Default, error: true }
figmaNode: "756:36"
elements:
outline:
background: { token: select/negative/default/background, value: "#060805" }
border-color: { token: select/negative/default/outline, value: "#f2705f" }
label:
color: { token: select/negative/default/label, value: "#e93120" }
field:
color: { token: select/negative/default/value, value: "#999999" }
chevron:
background: { token: select/negative/default/chevron, value: "#e93120" }
supportive:
color: { token: select/negative/default/supportive, value: "#e93120" }
- when: { state: Hover, error: true }
figmaNode: "756:43"
elements:
outline:
background: { token: select/negative/hover/background, value: "#171717" }
border-color: { token: select/negative/hover/outline, value: "#e93120" }
label:
color: { token: select/negative/hover/label, value: "#f2705f" }
field:
color: { token: select/negative/hover/value, value: "#999999" }
chevron:
background: { token: select/negative/hover/chevron, value: "#e93120" }
supportive:
color: { token: select/negative/hover/supportive, value: "#e93120" }
- when: { state: Focus, error: true }
figmaNode: "756:50"
elements:
outline:
background: { token: select/negative/focus/background, value: "#060805" }
border-color: { token: select/negative/focus/outline, value: "#f2705f" }
label:
color: { token: select/negative/focus/label, value: "#e93120" }
field:
color: { token: select/negative/focus/value, value: "#c2c7c3" }
chevron:
background: { token: select/negative/focus/chevron, value: "#e93120" }
supportive:
color: { token: select/negative/focus/supportive, value: "#e93120" }
focus-ring:
display: { value: block, assert: false }
border-color: { token: select/negative/focus/focus-ring, value: "#00d669" }
guidance:
status: proposed
use:
- title: Finding one in many
text: "A client out of a hundred, a country, a currency: a list long enough that typing a few letters beats scrolling."
show: "state=Default, error=False"
avoid:
- title: A short list
text: "Up to about fifteen options, a **Select** is simpler and uses the browser's own list."
- title: Free text
text: "When any answer is fine, not just one from the list, that's an **Input**."
behaviour: |-
It looks like Select and uses Select's colours. Typing opens the list and keeps the options whose name contains what was typed, ignoring case; nothing matching says so. Up and Down move the highlight, Enter picks it, Esc closes the list. Leaving the field puts the picked option's name back, so a half-typed word never looks like an answer.
accessibility:
element: "`<input role=\"combobox\">` with `aria-expanded`, `aria-controls` and `aria-activedescendant`, the ARIA pattern for a list that filters. The list is `role=\"listbox\"` of `role=\"option\"`s; the picked one has `aria-selected`."
name: "`label`."
keyboard: "The focus stays in the input the whole time; the highlight moves in the list and screen readers follow it through `aria-activedescendant`."
focus: "`focus-ring` around the field, on `:focus-visible`."
error: "`error` sets `aria-invalid` and ties the help line to the input."
colour: "Select's: the edge is 4.3:1 on the dark page. The empty-list words are 7:1."
content: "Option names people would type: the client's name, not an id."
Install
npx github:Runceanu/rost add combobox It lands in src/rost/combobox/, with what it needs and its contract. Install has the rest.
When to use
Finding one in many
A client out of a hundred, a country, a currency: a list long enough that typing a few letters beats scrolling.
When not to use
A short list
Up to about fifteen options, a Select is simpler and uses the browser's own list.
Free text
When any answer is fine, not just one from the list, that's an Input.
Behaviour
It looks like Select and uses Select's colours. Typing opens the list and keeps the options whose name contains what was typed, ignoring case; nothing matching says so. Up and Down move the highlight, Enter picks it, Esc closes the list. Leaving the field puts the picked option's name back, so a half-typed word never looks like an answer.
Accessibility
- Element
<input role="combobox">witharia-expanded,aria-controlsandaria-activedescendant, the ARIA pattern for a list that filters. The list isrole="listbox"ofrole="option"s; the picked one hasaria-selected. - Name
label. - Keyboard
The focus stays in the input the whole time; the highlight moves in the list and screen readers follow it through
aria-activedescendant. - Focus
focus-ringaround the field, on:focus-visible. - Error
errorsetsaria-invalidand ties the help line to the input. - Colour
Select's: the edge is 4.3:1 on the dark page. The empty-list words are 7:1.
Content
Option names people would type: the client's name, not an id.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
label | slot | | |
options | node | | |
value | string | | |
placeholder | string | | |
empty | string | | No match |
supportive | slot | | |
error | boolean | | false |
States: Default, Hover, Focus, Disabled.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
height56pxspacing/size/large -
width208pxno token yet
displayblock · positionrelative
outline
-
border-stylesolidno token yet -
border-width1pxspacing/outline/small -
border-radius12pxspacing/radius/medium
positionabsolute · inset0 · pointer-eventsnone
label
-
top12pxspacing/gap/small-medium -
left12pxspacing/gap/small-medium -
font-family'General Sans Variable'font-family/base -
font-weight400typography/label/font-weight/regular -
font-size10pxtypography/placeholder/font-size -
line-height12pxtypography/placeholder/line-height -
letter-spacing0pxtypography/placeholder/letter-spacing
positionabsolute · pointer-eventsnone
field
-
padding-top24pxspacing/gap/large -
padding-bottom12pxspacing/gap/small-medium -
padding-left12pxspacing/gap/small-medium -
padding-right40pxspacing/size/medium -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing
box-sizingborder-box · width100% · cursortext · positionabsolute · inset0 · appearancenone · backgroundtransparent · bordernone · outlinenone
chevron
-
top20pxspacing/gap/medium-large -
right12pxspacing/gap/small-medium -
width20pxspacing/size/xsmall -
height20pxspacing/size/xsmall -
maskurl(./icon-chevron.svg) center / contain no-repeaton purpose: The icon file itself.
positionabsolute · pointer-eventsnone
supportive
-
left12pxspacing/gap/small-medium -
topcalc(var(--spacing-size-large) + var(--spacing-gap-2xsmall))on purpose: Composed from tokens: the field's height plus spacing/gap/2xsmall. -
font-family'General Sans Variable'font-family/base -
font-weight500typography/label/font-weight/medium -
font-size10pxtypography/placeholder/font-size -
line-height12pxtypography/placeholder/line-height -
letter-spacing0pxtypography/placeholder/letter-spacing
positionabsolute · white-spacenowrap
focus-ring
-
border-stylesolidno token yet -
border-width2pxspacing/outline/medium -
border-radius16pxspacing/radius/large
displaynone · positionabsolute · insetcalc(-1 * var(--spacing-gap-2xsmall)) · pointer-eventsnone
listbox
-
margin0pxspacing/gap/none -
margin-block-start8pxspacing/gap/small -
max-height240pxno token yet -
padding4pxspacing/gap/2xsmall -
border-radius12pxspacing/radius/medium -
background#171717combobox/listbox/background -
outline-width1pxspacing/outline/small -
outline-offsetcalc(-1 * var(--spacing-outline-small))on purpose: Composed from a token: the edge sits inside the plate. -
outline-color#3a3a3acombobox/listbox/edge -
box-shadow0px 16px 24px 0px rgba(0, 0, 0, 0.16)shadow/floating
insetauto · position-areablock-end span-inline-end · position-try-fallbacksflip-block · min-widthanchor-size(width) · overflow-yauto · bordernone · outline-stylesolid · colorinherit
empty
-
height40pxspacing/size/medium -
padding-left12pxspacing/gap/small-medium -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#999999combobox/empty
displayflex · align-itemscenter
Changes by variant
7 variants. Each table is what one thing changes with: a column per error, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows error
Focus
| Property | Not error | Error |
|---|---|---|
focus-ring.border-colorselect/… | focus/focus-ring #00d669 | negative/focus/focus-ring #00d669 |
Follows state and error
Not error
| Property | Default | Hover | Focus | Disabled |
|---|---|---|---|---|
chevron.backgroundselect/… | default/chevron #00d669 | hover/chevron #00b450 | focus/chevron #00d669 | disabled/chevron #b6ffda |
field.colorselect/… | default/value #c2c7c3 | hover/value #d3d9d5 | focus/value #c2c7c3 | disabled/value #555555 |
label.colorselect/… | default/label #999999 | hover/label #d3d9d5 | focus/label #999999 | disabled/label #555555 |
outline.backgroundselect/… | default/background #060805 | hover/background #171717 | focus/background #060805 | disabled/background #171717 |
outline.border-colorselect/… | default/outline #747573 | hover/outline #999999 | focus/outline #747573 | disabled/outline #3a3a3a |
supportive.colorselect/… | default/supportive #999999 | hover/supportive #d3d9d5 | focus/supportive #999999 | disabled/supportive #555555 |
Error
| Property | Default | Hover | Focus | Disabled |
|---|---|---|---|---|
chevron.backgroundselect/negative/… | default/chevron #e93120 | hover/chevron #e93120 | focus/chevron #e93120 | · |
field.colorselect/negative/… | default/value #999999 | hover/value #999999 | focus/value #c2c7c3 | · |
label.colorselect/negative/… | default/label #e93120 | hover/label #f2705f | focus/label #e93120 | · |
outline.backgroundselect/negative/… | default/background #060805 | hover/background #171717 | focus/background #060805 | · |
outline.border-colorselect/negative/… | default/outline #f2705f | hover/outline #e93120 | focus/outline #f2705f | · |
supportive.colorselect/negative/… | default/supportive #e93120 | hover/supportive #e93120 | focus/supportive #e93120 | · |
Only in some variants
These don't change: they're just set in some variants and not others.
Disabled
-
chevron.opacity0.16opacity/soft
Focus
-
focus-ring.displayblocklayout
Part of Combobox
ComboboxOption
One option in a Combobox's list: a 40px row with its name. Green when it's highlighted, a green tick when it's the one picked.
Not selected · Not activeNot selected · ActiveSelected · Not activeSelected · Activesrc/components/combobox-option/ComboboxOption.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import './combobox-option.css'
export interface ComboboxOptionProps extends HTMLAttributes<HTMLDivElement> {
/** The picked one. */
readonly selected?: boolean
/** Highlighted by the arrow keys or the pointer. */
readonly active?: boolean
readonly children: ReactNode
}
const b = 'rost-combobox-option'
/** One option in a Combobox's list. Built from contracts/combobox-option.contract.yaml. */
export function ComboboxOption({ selected = false, active = false, children, className, ...rest }: ComboboxOptionProps) {
return (
<div role="option" aria-selected={selected} className={[b, selected && `${b}--selected`, active && `${b}--active`, className].filter(Boolean).join(' ')} {...rest}>
<span>{children}</span>
{selected && <span className={`${b}__check`} aria-hidden="true" />}
</div>
)
}
The source for everything on this page: contracts/combobox-option.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: combobox-option
name: ComboboxOption
kind: component
status: review
partOf: combobox
summary: "One option in a Combobox's list: a 40px row with its name. Green when it's highlighted, a green tick when it's the one picked."
category: inputs
related: [ combobox, menu-item ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "756:72"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=756-72
extractedAt: "2026-11-17"
extractedBy: hand
frozenAt: "2026-11-17"
props:
selected: { type: boolean, default: false, notes: "The picked one. Its name is medium weight and a tick sits at the end." }
active: { type: boolean, default: false, notes: "Highlighted, by the arrow keys or the pointer. Combobox sets it." }
children: { type: slot, required: true, notes: "The option's name." }
elements:
root:
notes: "A `role=\"option\"`, as wide as the list, 40px tall, 12px in at the sides, with 8px corners. MenuItem's row."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
justify-content: { value: space-between }
gap: { token: spacing/gap/small, value: 8px }
inline-size: { value: 100%, assert: false, notes: "As wide as the list." }
height: { token: spacing/size/medium, value: 40px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/gap/small-medium, value: 12px }
border-radius: { token: spacing/radius/small, value: 8px }
cursor: { value: pointer, assert: false }
white-space: { value: nowrap, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
check:
optional: true
notes: "Checkbox's tick, 16px, as a mask, on the picked option."
styles:
display: { value: block, assert: false }
flex-shrink: { value: "0", assert: false }
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
mask: { value: url(./icon-check.svg) center / contain no-repeat, untokenised: The icon file itself. }
variants:
- when: { selected: false, active: false }
figmaNode: "756:60"
elements:
root:
color: { token: combobox-option/default/label, value: "#ededed" }
- when: { selected: false, active: true }
figmaNode: "756:62"
elements:
root:
background: { token: combobox-option/active/background, value: "#006f27" }
color: { token: combobox-option/active/label, value: "#ededed" }
- when: { selected: true, active: false }
figmaNode: "756:64"
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
color: { token: combobox-option/default/label, value: "#ededed" }
check:
background: { token: combobox-option/check, value: "#00d669" }
- when: { selected: true, active: true }
figmaNode: "756:68"
elements:
root:
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
background: { token: combobox-option/active/background, value: "#006f27" }
color: { token: combobox-option/active/label, value: "#ededed" }
check:
background: { token: combobox-option/active/check, value: "#ededed", notes: "Green on green would vanish; on the highlight the tick takes the words' colour." }
guidance:
status: proposed
use:
- title: The picked one, and the one you're on
text: "Medium weight and a tick for the picked option; the green row for the one the arrow keys are on. They can be the same row."
show: "selected=True, active=False"
avoid:
- title: On its own
text: "An option only makes sense in a Combobox's list, which sets `active` and `selected`."
behaviour: "Pressing it picks it and closes the list. Pointing at it highlights it, as the arrow keys do."
accessibility:
element: "`role=\"option\"` with an id, so the input can point at it with `aria-activedescendant`. The picked one has `aria-selected=\"true\"`. The tick is drawing."
colour: "The names are 17:1 on the list's grey, 7:1 on the green. The tick is 10:1."
Install
npx github:Runceanu/rost add combobox-option It lands in src/rost/combobox-option/, with what it needs and its contract. Install has the rest.
When to use
The picked one, and the one you're on
Medium weight and a tick for the picked option; the green row for the one the arrow keys are on. They can be the same row.
When not to use
On its own
An option only makes sense in a Combobox's list, which sets
activeandselected.
Behaviour
Pressing it picks it and closes the list. Pointing at it highlights it, as the arrow keys do.
Accessibility
- Element
role="option"with an id, so the input can point at it witharia-activedescendant. The picked one hasaria-selected="true". The tick is drawing. - Colour
The names are 17:1 on the list's grey, 7:1 on the green. The tick is 10:1.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
selected | boolean | | false |
active | boolean | | false |
children | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap8pxspacing/gap/small -
height40pxspacing/size/medium -
padding-left12pxspacing/gap/small-medium -
padding-right12pxspacing/gap/small-medium -
border-radius8pxspacing/radius/small -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing
displayflex · align-itemscenter · justify-contentspace-between · inline-size100% · cursorpointer · white-spacenowrap
check
-
width16pxspacing/size/2xsmall -
height16pxspacing/size/2xsmall -
maskurl(./icon-check.svg) center / contain no-repeaton purpose: The icon file itself.
displayblock · flex-shrink0
Changes by variant
4 variants. Each table is what one thing changes with: a column per active, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows active
Selected
| Property | Not active | Active |
|---|---|---|
check.backgroundcombobox-option/… | check #00d669 | active/check #ededed |
| Property | Not active | Active |
|---|---|---|
root.colorcombobox-option/… | default/label #ededed | active/label #ededed |
Only in some variants
These don't change: they're just set in some variants and not others.
Active
-
root.background#006f27combobox-option/active/background
Selected
-
root.font-weight500typography/paragraph/font-weight/medium