Select
Dropdown select with aligned popup.
Installation
Usage
Examples
With label
Pair the select with a form label.
Grouped options
Group items under labels with separators. Items accept disabled.
Disabled
The whole select locks with a single prop.
API reference
Select
| Prop | Type | Default |
|---|---|---|
valueControlled selected value. Use with onValueChange. | string | - |
defaultValueInitially selected value when uncontrolled. | string | - |
onValueChangeCalled when the selection changes. | (value: string) => void | - |
openControlled open state. Use with onOpenChange. | boolean | - |
defaultOpenInitially open when uncontrolled. | boolean | false |
disabledDisable the trigger and popup. | boolean | false |
requiredRequire a selection before form submit. | boolean | false |
nameIdentifies the field when the form is submitted. | string | - |
SelectTrigger
| Prop | Type | Default |
|---|---|---|
sizeDensity. Both sizes currently share the h-8 height. | "sm" | "default" | "default" |
renderPolymorphic render prop. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default trigger styles. | string | - |
SelectValue
| Prop | Type | Default |
|---|---|---|
childrenPlaceholder rendered when nothing is selected. | ReactNode | - |
classNameAdditional classes merged with the default value styles. | string | - |
SelectContent
| Prop | Type | Default |
|---|---|---|
sidePreferred placement side. | "top" | "right" | "bottom" | "left" | "bottom" |
sideOffsetGap between trigger and popup. | number | 4 |
alignAlignment against the trigger edge. | "start" | "center" | "end" | "center" |
alignOffsetOffset along the alignment axis. | number | 0 |
alignItemWithTriggerLine up the selected item with the trigger. | boolean | true |
renderPolymorphic render prop. Use to render a custom element instead of the default popup. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default popup styles. | string | - |
SelectItem
| Prop | Type | Default |
|---|---|---|
valueValue set on the group when selected. | string | - |
disabledDisable the item. | boolean | false |
renderPolymorphic render prop. | ReactElement | ((props) => ReactNode) | - |
classNameAdditional classes merged with the default item styles. | string | - |
SelectGroup
| Prop | Type | Default |
|---|---|---|
classNameAdditional classes merged with the default group styles. | string | - |
SelectLabel
| Prop | Type | Default |
|---|---|---|
classNameAdditional classes merged with the default group label styles. | string | - |
SelectSeparator
| Prop | Type | Default |
|---|---|---|
classNameAdditional classes merged with the default separator styles. | string | - |