Select
A common form component for choosing a predefined value in a dropdown menu.
API reference
Import the component and assemble its parts:
import { Select } from '@base-ui-components/react/select';
<Select.Root> <Select.Trigger> <Select.Value /> <Select.Icon /> </Select.Trigger>
<Select.Portal> <Select.Backdrop /> <Select.Positioner> <Select.ScrollUpArrow /> <Select.Popup> <Select.Arrow /> <Select.Item> <Select.ItemText /> <Select.ItemIndicator /> </Select.Item> <Select.Separator /> <Select.Group> <Select.GroupLabel /> </Select.Group> </Select.Popup> <Select.ScrollDownArrow /> </Select.Positioner> </Select.Portal></Select.Root>
Root
Groups all parts of the select. Doesn’t render its own HTML element.
Prop | Type | Default | |
---|---|---|---|
name |
|
| |
defaultValue |
|
| |
value |
|
| |
onValueChange |
|
| |
defaultOpen |
|
| |
open |
|
| |
onOpenChange |
|
| |
alignItemToTrigger |
|
| |
modal |
|
| |
disabled |
|
| |
readOnly |
|
| |
required |
|
|
Trigger
A button that opens the select menu.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
disabled |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-popup-open | Present when the corresponding select is open. | |
data-pressed | Present when the trigger is pressed. | |
data-disabled | Present when the select is disabled. | |
data-readonly | Present when the select is readonly. | |
data-required | Present when the select is required. | |
data-valid | Present when the select is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the select is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the select's value has changed (when wrapped in Field.Root). | |
data-touched | Present when the select has been touched (when wrapped in Field.Root). |
Value
A text label of the currently selected item.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
placeholder |
|
| |
children |
|
| |
className |
|
| |
render |
|
|
Icon
An icon that indicates that the trigger button opens a select menu.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Backdrop
An overlay displayed beneath the menu popup.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
keepMounted |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the select is open. | |
data-closed | Present when the select is closed. | |
data-starting-style | Present when the select is animating in. | |
data-ending-style | Present when the select is animating out. |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>
.
Prop | Type | Default | |
---|---|---|---|
container |
|
|
Positioner
Positions the select menu popup against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align |
|
| |
alignOffset |
|
| |
side |
|
| |
sideOffset |
|
| |
arrowPadding |
|
| |
anchor |
|
| |
collisionBoundary |
|
| |
collisionPadding |
|
| |
sticky |
|
| |
positionMethod |
|
| |
trackAnchor |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the select popup is open. | |
data-closed | Present when the select popup is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the select is positioned relative to the trigger. |
CSS Variable | Description | |
---|---|---|
--anchor-height | The anchor's height. | |
--anchor-width | The anchor's width. | |
--available-height | The available height between the trigger and the edge of the viewport. | |
--available-width | The available width between the trigger and the edge of the viewport. | |
--transform-origin | The coordinates that this element is anchored to. Used for animations and transitions. |
Popup
A container for the select items.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the select is open. | |
data-closed | Present when the select is closed. | |
data-side | Indicates which side the select is positioned relative to the trigger. | |
data-starting-style | Present when the select is animating in. | |
data-ending-style | Present when the select is animating out. |
Arrow
Displays an element positioned against the select menu anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the select popup is open. | |
data-closed | Present when the select popup is closed. | |
data-uncentered | Present when the select arrow is uncentered. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the select is positioned relative to the trigger. |
Item
An individual option in the select menu.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
label |
|
| |
value |
|
| |
disabled |
|
|
ItemText
A text label of the select item.
Renders a <div>
element.
ItemIndicator
Indicates whether the select item is selected.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
keepMounted |
|
| |
render |
|
|
Group
Groups related select items with the corresponding label.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
ScrollUpArrow
An element that scrolls the select menu down when hovered.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
keepMounted |
|
|
Attribute | Description | |
---|---|---|
data-direction | Indicates the direction of the arrow. | |
data-side | Indicates which side the arrow is positioned relative to the select. | |
data-visible | Present when the arrow is visible. |
ScrollDownArrow
An element that scrolls the select menu down when hovered.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
keepMounted |
|
|
Attribute | Description | |
---|---|---|
data-direction | Indicates the direction of the arrow. | |
data-side | Indicates which side the arrow is positioned relative to the select. | |
data-visible | Present when the arrow is visible. |
Separator
A separator element accessible to screen readers.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|