Select
A common form component for choosing a predefined value in a dropdown menu.
API reference
Import the component and place its parts the following way:
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 | |
---|---|---|---|
alignItemToTrigger | boolean | true | |
defaultOpen | boolean | false | |
defaultValue | any | null | |
disabled | boolean | false | |
name | string | undefined | |
onOpenChange | function | undefined | |
onValueChange | function | undefined | |
open | boolean | undefined | |
readOnly | boolean | false | |
required | boolean | false | |
value | any | undefined |
Trigger
A button that opens the select menu.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
label | string | undefined | |
render | | React.ReactElement | undefined |
Value
A text label of the currently selected item.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
placeholder | string | undefined | |
render | | React.ReactElement | undefined |
Icon
An icon that indicates that the trigger button opens a select menu.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Backdrop
An overlay displayed beneath the menu popup.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to the <body>
.
Prop | Type | Default | |
---|---|---|---|
container | React.Ref | HTMLElement | null | undefined |
Positioner
Positions the select menu popup against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align | 'start' | 'center' | 'end' | 'start' | |
alignOffset | number | 0 | |
anchor | | React.Ref | undefined | |
arrowPadding | number | 5 | |
className | string | (state) => string | undefined | |
collisionBoundary | | 'clippingAncestors' | 'clipping-ancestors' | |
collisionPadding | number | Rect | 5 | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
render | | React.ReactElement | undefined | |
side | | 'bottom' | 'bottom' | |
sideOffset | number | 0 | |
sticky | boolean | false | |
trackAnchor | boolean | true |
CSS Variable | Type | |
---|---|---|
--anchor-height | number | |
--anchor-width | number | |
--available-height | number | |
--available-width | number | |
--transform-origin | string |
Popup
A container for the select items.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
id | string | undefined | |
render | | React.ReactElement | undefined |
Arrow
Displays an element positioned against the select menu anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Item
An individual option in the select menu.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
disabled | boolean | false | |
label | string | undefined | |
value | any | null |
Item Text
A text label of the select item.
Renders a <div>
element.
Prop | Type | Default |
---|
Item Indicator
Indicates whether the select item is selected.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined |
Group
Groups related select items with the corresponding label.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Group Label
An accessible label that is automatically associated with its parent group.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Scroll Up Arrow
An element that scrolls the select menu down when hovered.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
keepMounted | boolean | false |
Scroll Down Arrow
An element that scrolls the select menu down when hovered.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
keepMounted | boolean | false |
Separator
A separator element accessible to screen readers.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |