Select
Status: stableAccessibility reviewedtenet-ui@0.4.0
import { Select } from 'tenet-ui';Also accepts every prop of Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue'>.
Source: src/components/Select/Select.tsx
Usage guidelines
Section titled “Usage guidelines”When to use: choosing one option from a known list. Select is a fully accessible listbox combobox (keyboard, typeahead, aria-activedescendant) — not a native <select>. Use it inside a FormControl.
- Give it an accessible name via
FormControl.Labeloraria-label. - Pass choices as the
optionsarray ({ value, label, disabled? }); useplaceholderfor the unselected state. - Control it with
value+onChange(value), or leave uncontrolled withdefaultValue. For form submission, passname(it emits a hidden input). - Use
size/fullWidthfrom the scale (blockis the deprecated 0.3.0 name and warns); useinvalidfor validation state. - Never build a div-based dropdown by hand — getting the ARIA listbox + keyboard right is exactly what this component does for you.
Do / Don’t
Section titled “Do / Don’t”- ✅
<Select options={[{ value: 'public', label: 'Public' }]} placeholder="Choose…" /> - ✅ inside a form:
<FormControl><FormControl.Label>Visibility</FormControl.Label><Select options={…} /></FormControl> - ❌
<div className="dropdown" onClick={…}>— not keyboard-accessible, no roles, no typeahead.
See also: Menu for actions, RadioGroup or SegmentedControl for a few visible options; system guideline forms.
Examples
Section titled “Examples”3 stories for Select — open in Storybook
- Default
components-select--default - With Placeholder
components-select--with-placeholder - With Disabled Option
components-select--with-disabled-option
The full matrix (all args, controls, accessibility panel) is in Storybook.
| Prop | Type | Default | Description |
|---|---|---|---|
options * | SelectOption[] | — | The options to choose from. |
value | string | — | Controlled selected value. |
defaultValue | string | — | Uncontrolled initial value. |
onChange | (value: string) => void | — | Called with the newly selected value. |
placeholder | string | Select… | Text shown when nothing is selected. |
size | 'small' | 'medium' | 'large'SelectSize | medium | Control height / font scale. |
fullWidth | boolean | — | Stretch to fill the available width. |
blockdeprecated | boolean | — | Stretch to fill the available width. Deprecated since 0.4.0. Use fullWidth instead (renamed in 0.4.0). block keeps working until 0.5.0. |
invalid | boolean | false | Invalid state (danger border + aria-invalid). |
disabled | boolean | false | Disable the control. |
required | boolean | false | Required (sets aria-required; pairs with FormControl). |
name | string | — | Form field name — emits a hidden input so the value submits with a form. |
id | string | — | Id applied to the trigger (FormControl sets this automatically). |
className | string | — | |
aria-label | string | — | |
aria-describedby | string | — |
* requiredDeprecated props keep working for one minor release; the replacement is named in the row.
Related types
SelectOption
| Member | Type | Default | Description |
|---|---|---|---|
value * | string | — | Value submitted / reported on change. |
label * | string | — | Visible option text. |
disabled | boolean | — | Disable this option. |