ComponentsForms
Select
Pick one option from a list, with full keyboard support.
Pick one option from a list, with full keyboard support.
<Select>
<SelectTrigger>
<SelectValue placeholder="Pick a frequency" />
</SelectTrigger>
<SelectContent>
<SelectItem value="daily">Daily</SelectItem>
<SelectItem value="weekly">Weekly</SelectItem>
<SelectItem value="monthly">Monthly</SelectItem>
</SelectContent>
</Select>The same component at all four levels. Pick the one that fits your project; they share tokens, so they mix.
npm i junco @junco/tailwindimport { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "junco";
<Field label="Frequency">
<Select defaultValue="weekly">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="daily">Daily</SelectItem>
<SelectItem value="weekly">Weekly</SelectItem>
</SelectContent>
</Select>
</Field>Group long lists with SelectGroup, SelectLabel and SelectSeparator.
Field labels the trigger and links the error to it.
Pick a plan to continue.
Select#value / defaultValueonValueChangedisabledname| Prop | Type | Default |
|---|---|---|
value / defaultValueControlled or initial value. | string | – |
onValueChangeCalled when the user picks an option. | (value: string) => void | – |
disabledDisables the whole select. | boolean | false |
nameForm field name, for native form submission. | string | – |
SelectTrigger#sizeisInvalid| Prop | Type | Default |
|---|---|---|
sizeMatches Input sizes. | "sm" | "md" | "lg" | "md" |
isInvalidSets aria-invalid and the error border. | boolean | false |
SelectItem#valuedisabled| Prop | Type | Default |
|---|---|---|
valueRequired. The value reported when picked. | string | – |
disabledSkipped by the keyboard and not selectable. | boolean | false |
| Key | Action |
|---|---|
| Space | Opens the list when the trigger is focused, or picks the highlighted option. |
| Enter | Opens the list, or picks the highlighted option. |
| ↑↓ | Moves the highlight. |
| Esc | Closes the list and returns focus to the trigger. |
| A–Z | Typeahead: jumps to the first option starting with that letter. |