<Select.Root>
<Select.Trigger className="w-56">
<Select.Value placeholder="Select a specialty" />
</Select.Trigger>
<Select.Content>
<Select.Group>
<Select.Label>Creative</Select.Label>
<Select.Item value="designer">Designer</Select.Item>
</Select.Group>
</Select.Content>
</Select.Root>To show a label rather than the raw value on a controlled select, pass items
as a value-to-label record — otherwise the trigger shows brand-refresh
instead of "Brand refresh".
More than a dozen options wants Combobox; a phone-first form wants ResponsiveSelect.
API
Select.Root
| Prop | Type | Default | |
|---|---|---|---|
actionsRef | RefObject<SelectRootActions | null> | — | A ref to imperative actions. |
autoComplete | string | — | Provides a hint to the browser for autofill. |
children | ReactNode | — | |
defaultOpen | boolean | — | Whether the select popup is initially open. To render a controlled select popup, use the open prop instead. |
defaultValue | SelectValueType<Value, Multiple> | null | — | The uncontrolled value of the select when it's initially rendered. To render a controlled select, use the value prop instead. |
disabled | boolean | — | Whether the component should ignore user interaction. |
form | string | — | Identifies the form that owns the hidden input. Useful when the select is rendered outside the form. |
highlightItemOnHover | boolean | — | Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state. |
id | string | — | The id of the Select. |
inputRef | Ref<HTMLInputElement> | — | A ref to access the hidden input element. |
isItemEqualToValue | ((itemValue: Value, value: Value) => boolean) | — | Custom comparison logic used to determine if a select item value matches the current selected value. Useful when item values are objects without matching referentially.
Defaults to Object.is comparison. |
items | readonly Group<any>[] | readonly { label: ReactNode; value: any; }[] | Record<string, ReactNode> | — | Data structure of the items rendered in the select popup.
When specified, <Select.Value> renders the label of the selected item instead of the raw value. |
itemToStringLabel | ((itemValue: Value) => string) | — | When the item values are objects (<Select.Item value={object}>), this function converts the object value to a string representation for display in the trigger.
If the shape of the object is { value, label }, the label will be used automatically without needing to specify this prop. |
itemToStringValue | ((itemValue: Value) => string) | — | When the item values are objects (<Select.Item value={object}>), this function converts the object value to a string representation for form submission.
If the shape of the object is { value, label }, the value will be used automatically without needing to specify this prop. |
modal | boolean | — | Determines if the select enters a modal state when open. |
multiple | Multiple | — | Whether multiple items can be selected. |
name | string | — | Identifies the field when a form is submitted. |
onOpenChange | ((open: boolean, eventDetails: SelectRootChangeEventDetails) => void) | — | Event handler called when the select popup is opened or closed. |
onOpenChangeComplete | ((open: boolean) => void) | — | Event handler called after any animations complete when the select popup is opened or closed. |
onValueChange | ((value: SelectValueType<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: SelectRootChangeEventDetails) => void) | — | Event handler called when the value of the select changes. |
open | boolean | — | Whether the select popup is currently open. |
readOnly | boolean | — | Whether the user should be unable to choose a different option from the select popup. |
required | boolean | — | Whether the user must choose a value before submitting a form. |
value | SelectValueType<Value, Multiple> | null | — | The value of the select. Use when controlled. |
Plus the DOM props of the element it renders. Source: select/components/select-root.tsx.
Select.Content
| Prop | Type | Default | |
|---|---|---|---|
align | Align | "center" | How to align the popup relative to the specified side. |
alignItemWithTrigger | boolean | true | Whether the positioner overlaps the trigger so the selected item's text is aligned with the trigger's value text. This only applies to mouse input and is automatically disabled if there is not enough space. |
alignOffset | number | OffsetFunction | 0 | Additional offset along the alignment axis in pixels.
Also accepts a function that returns the offset to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: |
children | ReactNode | — | |
className | string | ((state: SelectPopupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
collisionPadding | Padding | — | Additional space to maintain from the edge of the collision boundary. |
finalFocus | boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | — | Determines the element to focus when the select popup is closed. |
render | ComponentRenderFn<HTMLProps, SelectPopupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
side | Side | "bottom" | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
sideOffset | number | OffsetFunction | 4 | Distance between the anchor and the popup in pixels.
Also accepts a function that returns the distance to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: |
style | CSSProperties | ((state: SelectPopupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-content.tsx.
Select.Group
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectGroupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, SelectGroupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectGroupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-group.tsx.
Select.Item
| Prop | Type | Default | |
|---|---|---|---|
children | ReactNode | — | |
className | string | ((state: SelectItemState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
label | string | — | Specifies the text label to use when the item is matched during keyboard text navigation. Defaults to the item text content if not provided. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
render | ComponentRenderFn<HTMLProps, SelectItemState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectItemState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
value | any | — | A unique value that identifies this select item. |
Plus the DOM props of the element it renders. Source: select/components/select-item.tsx.
Select.Label
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectGroupLabelState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, SelectGroupLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectGroupLabelState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-label.tsx.
Select.ScrollDownButton
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectScrollDownArrowState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
keepMounted | boolean | — | Whether to keep the HTML element in the DOM while the select popup is not scrollable. |
render | ComponentRenderFn<HTMLProps, SelectScrollDownArrowState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectScrollDownArrowState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-scroll-down-button.tsx.
Select.ScrollUpButton
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectScrollUpArrowState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
keepMounted | boolean | — | Whether to keep the HTML element in the DOM while the select popup is not scrollable. |
render | ComponentRenderFn<HTMLProps, SelectScrollUpArrowState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectScrollUpArrowState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-scroll-up-button.tsx.
Select.Separator
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SeparatorState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
orientation | Orientation | — | The orientation of the separator. |
render | ComponentRenderFn<HTMLProps, SeparatorState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SeparatorState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-separator.tsx.
Select.Trigger
| Prop | Type | Default | |
|---|---|---|---|
size | "default" | "sm" | "default" | |
children | ReactNode | — | |
className | string | ((state: SelectTriggerState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>). |
render | ComponentRenderFn<HTMLProps, SelectTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectTriggerState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-trigger.tsx.
Select.Value
| Prop | Type | Default | |
|---|---|---|---|
children | ((value: any) => ReactNode) | ReactNode | — | Accepts a function that returns a ReactNode to format the selected value. |
className | string | ((state: SelectValueState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
placeholder | ReactNode | — | The placeholder value to display when no value is selected.
This is overridden by children if specified, or by a null item's label in items. |
render | ComponentRenderFn<HTMLProps, SelectValueState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectValueState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: select/components/select-value.tsx.