component
Select
One choice from a list that's too long to show. Input's filled field, with a chevron, and the browser's own list when it opens.
Try it
Every variant
Default · Not errorDisabled · Not errorDefault · ErrorHover, press or tab to one to see the other 4 states.
import { Select } from 'rost/components/select/Select'
<Select label="Currency" value={currency} onChange={(e) => setCurrency(e.target.value)}>
<option value="eur">Euro</option>
<option value="ron">Romanian leu</option>
</Select> src/components/select/Select.tsx
import { useId, type ReactNode, type SelectHTMLAttributes } from 'react'
import './select.css'
export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
/** The field's name, small at the top. */
readonly label: ReactNode
/** The `<option>`s. */
readonly children?: ReactNode
/** One line under the field: help, or what to fix. */
readonly supportive?: ReactNode
/** Input's red. Say what's wrong in `supportive`. */
readonly error?: boolean
}
const b = 'rost-select'
/**
* One choice from a long list. A real `<select>` over Input's filled field, so
* the list that opens is the browser's own. Built from
* contracts/select.contract.yaml.
*/
export function Select({ label, children, supportive, error = false, id, className, style, ...rest }: SelectProps) {
const made = useId()
const fieldId = id ?? made
const helpId = `${fieldId}-help`
return (
<div className={[b, error && `${b}--error`, className].filter(Boolean).join(' ')} style={style}>
<span className={`${b}__outline`} aria-hidden="true" />
<select id={fieldId} className={`${b}__field`} aria-invalid={error || undefined} aria-describedby={supportive != null ? helpId : undefined} {...rest}>{children}</select>
<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>
)
}
The source for everything on this page: contracts/select.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: select
name: Select
kind: component
status: review
summary: One choice from a list that's too long to show. Input's filled field, with a chevron, and the browser's own list when it opens.
category: inputs
related: [ input, radio, menu ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "738:29"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=738-29
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
label: { type: slot, required: true, notes: "The field's name. It sits small at the top, the way Input's label does once it has a value: a select always has one." }
children: { type: slot, notes: "The `<option>`s, as in any `<select>`." }
supportive: { type: slot, notes: "One line under the field: help, or what to fix when `error` is on." }
error: { type: boolean, default: false, notes: "Input's red: the edge, the label, the chevron and the help line. Say what's wrong in `supportive`." }
states: [ Default, Hover, Focus, Disabled ]
stateSelectors:
Focus: ":has(> .rost-select__field:focus-visible)"
Disabled: ":has(> .rost-select__field:disabled)"
elements:
root:
notes: "A box the size of Input, holding the parts. The `<select>` covers all of it, so a press anywhere 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: "Input's label once it's filled: placeholder type, 12px in from the edges. A `<label>` for the select."
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: "The real `<select>`, over the whole box. Its own look goes; its value sits where Input's does, under the label."
styles:
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 }
cursor: { value: pointer, 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 }
variants:
- when: { state: Default, error: false }
figmaNode: "738:3"
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: "738:9"
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: "738:15"
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: "738:22"
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: "741:35"
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: "741:42"
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: "741:49"
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: One out of many
text: "A choice from a list of six or more, or a list that changes: a country, a client, a currency."
show: state=Default, error=False
avoid:
- title: A few choices
text: "Five or fewer, where seeing them all helps. That's **Radio**."
- title: Actions
text: "A list of things to do, not a value to pick. That's **Menu**."
behaviour: |-
It looks like Input once Input has a value: the label small at the top, the value under it, and a chevron on the right. The list that opens is the browser's own, so it works with the keyboard, on a phone and with a screen reader without any work of mine, but I can't style it. With `error` it takes Input's red, and the help line under it says what to fix. A disabled select has no error look: there's nothing to fix in a field you can't change.
accessibility:
element: "A real `<select>`, named by its `<label>`."
name: "`label`. Keep it short: it's the question the value answers."
keyboard: "Tab reaches it. Space, Enter or the arrow keys open it and move through it, the browser's way."
focus: "`focus-ring` around the field, on `:focus-visible`."
error: "`error` sets `aria-invalid`, and the help line is tied to the select with `aria-describedby`, so the reason is read out with it. Red is never the only sign: the words say what's wrong."
colour: "The field's edge is 4.3:1 on the dark page, the same as Input's."
content: "Options in sentence case, in an order that makes sense: alphabetical, or the most likely first."
Install
npx github:Runceanu/rost add select It lands in src/rost/select/, with what it needs and its contract. Install has the rest.
When to use
One out of many
A choice from a list of six or more, or a list that changes: a country, a client, a currency.
When not to use
Behaviour
It looks like Input once Input has a value: the label small at the top, the value under it, and a chevron on the right. The list that opens is the browser's own, so it works with the keyboard, on a phone and with a screen reader without any work of mine, but I can't style it. With error it takes Input's red, and the help line under it says what to fix. A disabled select has no error look: there's nothing to fix in a field you can't change.
Accessibility
- Element
A real
<select>, named by its<label>. - Name
label. Keep it short: it's the question the value answers. - Keyboard
Tab reaches it. Space, Enter or the arrow keys open it and move through it, the browser's way.
- Focus
focus-ringaround the field, on:focus-visible. - Error
errorsetsaria-invalid, and the help line is tied to the select witharia-describedby, so the reason is read out with it. Red is never the only sign: the words say what's wrong. - Colour
The field's edge is 4.3:1 on the dark page, the same as Input's.
Content
Options in sentence case, in an order that makes sense: alphabetical, or the most likely first.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
label | slot | | |
children | slot | | |
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
positionabsolute · inset0 · appearancenone · backgroundtransparent · bordernone · outlinenone · cursorpointer
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
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