Select
A common form component for choosing a predefined value in a dropdown menu.
View as MarkdownUsage guidelines
- Prefer Combobox for large lists: Select is not filterable, aside from basic keyboard typeahead functionality to find items by focusing and highlighting them. Prefer Combobox instead of Select when the number of items is sufficiently large to warrant filtering.
Anatomy
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>API reference
Root
Groups all parts of the select. Doesn’t render its own HTML element.
namestring
string- Name
- Description
- Identifies the field when a form is submitted. 
- Type
- string | undefined
defaultValueUnion
(default: null
)
Unionnull- Name
- Description
- The uncontrolled value of the select when it’s initially rendered. - To render a controlled select, use the - valueprop instead.
- Type
- Value[] | Value | null | undefined
- Default
- null
valueValue[] | Value
Value[] | Value- Name
- Description
- The value of the select. 
- Type
- Value[] | Value | undefined
onValueChangefunction
function- Name
- Description
- Callback fired when the value of the select changes. Use when controlled. 
- Type
- | (( value: Value[] | Value, eventDetails: Select.Root.ChangeEventDetails, ) => void) | undefined
defaultOpenboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the select menu is initially open. - To render a controlled select menu, use the - openprop instead.
- Type
- boolean | undefined
- Default
- false
openboolean
boolean- Name
- Description
- Whether the select menu is currently open. 
- Type
- boolean | undefined
onOpenChangefunction
function- Name
- Description
- Event handler called when the select menu is opened or closed. 
- Type
- | (( open: boolean, eventDetails: Select.Root.ChangeEventDetails, ) => void) | undefined
actionsRefRefObject<Select.Root.Actions>
RefObject<Select.Root.Actions>- Name
- Description
- A ref to imperative actions. - unmount: When specified, the select will not be unmounted when closed. Instead, the- unmountfunction must be called to unmount the select manually. Useful when the select's animation is controlled by an external library.
 
- Type
- React.RefObject<Select.Root.Actions> | undefined
itemsUnion
Union- Name
- Description
- Data structure of the items rendered in the select menu. When specified, - <Select.Value>renders the label of the selected item instead of the raw value.
- Type
- | Record<string, ReactNode> | { label: ReactNode; value: Value }[] | undefined
- Example
- const items = { sans: 'Sans-serif', serif: 'Serif', mono: 'Monospace', cursive: 'Cursive', }; <Select.Root items={items} />
modalboolean
(default: true
)
booleantrue- Name
- Description
- Determines if the select enters a modal state when open. - true: user interaction is limited to the select: document page scroll is locked and and pointer interactions on outside elements are disabled.
- false: user interaction with the rest of the document is allowed.
 
- Type
- boolean | undefined
- Default
- true
multipleboolean | undefined
(default: false
)
boolean | undefinedfalse- Name
- Description
- Whether multiple items can be selected. 
- Type
- boolean | undefined | undefined
- Default
- false
onOpenChangeCompletefunction
function- Description
- Event handler called after any animations complete when the select menu is opened or closed. 
- Type
- ((open: boolean) => void) | undefined
disabledboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the component should ignore user interaction. 
- Type
- boolean | undefined
- Default
- false
readOnlyboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the user should be unable to choose a different option from the select menu. 
- Type
- boolean | undefined
- Default
- false
requiredboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the user must choose a value before submitting a form. 
- Type
- boolean | undefined
- Default
- false
inputRefRef<HTMLInputElement>
Ref<HTMLInputElement>- Name
- Description
- A ref to access the hidden input element. 
- Type
- React.Ref<HTMLInputElement> | undefined
idstring
string- Name
- Description
- The id of the Select. 
- Type
- string | undefined
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode | undefined
Trigger
A button that opens the select menu.
Renders a <div> element.
nativeButtonboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the component renders a native - <button>element when replacing it via the- renderprop. Set to- trueif the rendered element is a native button.
- Type
- boolean | undefined
- Default
- false
disabledboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the component should ignore user interaction. 
- Type
- boolean | undefined
- Default
- false
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Trigger.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Trigger.State, ) => ReactElement)
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).
data-filled
Present when the select has a value (when wrapped in Field.Root).
data-focused
Present when the select trigger is focused (when wrapped in Field.Root).
Value
A text label of the currently selected item.
Renders a <span> element.
childrenReactNode | ((value: any) => ReactNode)
ReactNode | ((value: any) => ReactNode)- Name
- Description
- Accepts a function that returns a - ReactNodeto format the selected value.
- Type
- React.ReactNode | ((value: any) => ReactNode)
- Example
- <Select.Value> {(value: string | null) => value ? labels[value] : 'No value'} </Select.Value>
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Value.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Value.State, ) => ReactElement)
Icon
An icon that indicates that the trigger button opens a select menu.
Renders a <span> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Icon.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Icon.State, ) => ReactElement)
data-popup-open
Present when the corresponding popup is open.
Backdrop
An overlay displayed beneath the menu popup.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Backdrop.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Backdrop.State, ) => ReactElement)
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>.
containerUnion
Union- Name
- Description
- A parent element to render the portal element into. 
- Type
- | HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undefined
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode
Positioner
Positions the select menu popup.
Renders a <div> element.
alignItemWithTriggerboolean
(default: true
)
booleantrue- Description
- 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. 
- Type
- boolean | undefined
- Default
- true
collisionAvoidanceCollisionAvoidance
CollisionAvoidance- Description
- Determines how to handle collisions when positioning the popup. 
- Type
- | { side?: 'none' | 'flip' align?: 'shift' | 'none' | 'flip' fallbackAxisSide?: 'none' | 'start' | 'end' } | { side?: 'shift' | 'none' align?: 'shift' | 'none' fallbackAxisSide?: 'none' | 'start' | 'end' } | undefined
- Example
- <Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} />
alignAlign
(default: 'center'
)
Align'center'- Name
- Description
- How to align the popup relative to the specified side. 
- Type
- 'center' | 'start' | 'end' | undefined
- Default
- 'center'
alignOffsetnumber | OffsetFunction
(default: 0
)
number | OffsetFunction0- Name
- Description
- 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 - dataobject parameter with the following properties:- data.anchor: the dimensions of the anchor element with properties- widthand- height.
- data.positioner: the dimensions of the positioner element with properties- widthand- height.
- data.side: which side of the anchor element the positioner is aligned against.
- data.align: how the positioner is aligned relative to the specified side.
 
- Type
- | number | ((data: { side: Side align: Align anchor: { width: number; height: number } positioner: { width: number; height: number } }) => number) | undefined
- Default
- 0
- Example
- <Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} />
sideSide
(default: 'bottom'
)
Side'bottom'- Name
- Description
- Which side of the anchor element to align the popup against. May automatically change to avoid collisions. 
- Type
- | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | undefined
- Default
- 'bottom'
sideOffsetnumber | OffsetFunction
(default: 0
)
number | OffsetFunction0- Name
- Description
- 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 - dataobject parameter with the following properties:- data.anchor: the dimensions of the anchor element with properties- widthand- height.
- data.positioner: the dimensions of the positioner element with properties- widthand- height.
- data.side: which side of the anchor element the positioner is aligned against.
- data.align: how the positioner is aligned relative to the specified side.
 
- Type
- | number | ((data: { side: Side align: Align anchor: { width: number; height: number } positioner: { width: number; height: number } }) => number) | undefined
- Default
- 0
- Example
- <Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} />
arrowPaddingnumber
(default: 5
)
number5- Name
- Description
- Minimum distance to maintain between the arrow and the edges of the popup. - Use it to prevent the arrow element from hanging out of the rounded corners of a popup. 
- Type
- number | undefined
- Default
- 5
anchorUnion
Union- Name
- Description
- An element to position the popup against. By default, the popup will be positioned against the trigger. 
- Type
- | Element | React.RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | null | undefined
collisionBoundaryBoundary
(default: 'clipping-ancestors'
)
Boundary'clipping-ancestors'- Description
- An element or a rectangle that delimits the area that the popup is confined to. 
- Type
- | Element | 'clipping-ancestors' | Element[] | Rect | undefined
- Default
- 'clipping-ancestors'
collisionPaddingPadding
(default: 5
)
Padding5- Name
- Description
- Additional space to maintain from the edge of the collision boundary. 
- Type
- | { top?: number right?: number bottom?: number left?: number } | number | undefined
- Default
- 5
stickyboolean
(default: false
)
booleanfalse- Name
- Description
- Whether to maintain the popup in the viewport after the anchor element was scrolled out of view. 
- Type
- boolean | undefined
- Default
- false
positionMethod'fixed' | 'absolute'
(default: 'absolute'
)
'fixed' | 'absolute''absolute'- Name
- Description
- Determines which CSS - positionproperty to use.
- Type
- 'fixed' | 'absolute' | undefined
- Default
- 'absolute'
trackAnchorboolean
(default: true
)
booleantrue- Name
- Description
- Whether the popup tracks any layout shift of its positioning anchor. 
- Type
- boolean | undefined
- Default
- true
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: Select.Positioner.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Positioner.State, ) => ReactElement)
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-align
Indicates how the popup is aligned relative to specified side.
data-side
Indicates which side the popup is positioned relative to the trigger.
--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.
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Popup.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Popup.State, ) => ReactElement)
data-open
Present when the select is open.
data-closed
Present when the select is closed.
data-align
Indicates how the popup is aligned relative to specified side.
data-side
Indicates which side the popup 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.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Arrow.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Arrow.State, ) => ReactElement)
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-align
Indicates how the popup is aligned relative to specified side.
data-side
Indicates which side the popup is positioned relative to the trigger.
Item
An individual option in the select menu.
Renders a <div> element.
labelstring
string- Name
- Description
- Specifies the text label to use when the item is matched during keyboard text navigation. - Defaults to the item text content if not provided. 
- Type
- string | undefined
valueany
(default: null
)
anynull- Name
- Description
- A unique value that identifies this select item. 
- Type
- any
- Default
- null
nativeButtonboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the component renders a native - <button>element when replacing it via the- renderprop. Set to- trueif the rendered element is a native button.
- Type
- boolean | undefined
- Default
- false
disabledboolean
(default: false
)
booleanfalse- Name
- Description
- Whether the component should ignore user interaction. 
- Type
- boolean | undefined
- Default
- false
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Item.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Item.State, ) => ReactElement)
data-selected
Present when the select item is selected.
data-highlighted
Present when the select item is highlighted.
data-disabled
Present when the select item is disabled.
ItemText
A text label of the select item.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.ItemText.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.ItemText.State, ) => ReactElement)
ItemIndicator
Indicates whether the select item is selected.
Renders a <span> element.
childrenReactNode
ReactNode- Name
- Type
- React.ReactNode
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: Select.ItemIndicator.State) => string)
keepMountedboolean
(default: false
)
booleanfalse- Name
- Description
- Whether to keep the HTML element in the DOM when the item is not selected. 
- Type
- boolean | undefined
- Default
- false
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.ItemIndicator.State, ) => ReactElement)
Group
Groups related select items with the corresponding label.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Select.Group.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.Group.State, ) => ReactElement)
GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: Select.GroupLabel.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.GroupLabel.State, ) => ReactElement)
ScrollUpArrow
An element that scrolls the select menu up when hovered.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: Select.ScrollUpArrow.State) => string)
keepMountedboolean
(default: false
)
booleanfalse- Name
- Description
- Whether to keep the HTML element in the DOM while the select menu is not scrollable. 
- Type
- boolean | undefined
- Default
- false
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.ScrollUpArrow.State, ) => ReactElement)
data-direction
Indicates the direction of the scroll arrow.
data-side
Indicates which side the popup is positioned relative to the trigger.
data-visible
Present when the scroll arrow is visible.
data-starting-style
Present when the scroll arrow is animating in.
data-ending-style
Present when the scroll arrow is animating out.
ScrollDownArrow
An element that scrolls the select menu down when hovered.
Renders a <div> element.
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- | string | ((state: Select.ScrollDownArrow.State) => string)
keepMountedboolean
(default: false
)
booleanfalse- Name
- Description
- Whether to keep the HTML element in the DOM while the select menu is not scrollable. 
- Type
- boolean | undefined
- Default
- false
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Select.ScrollDownArrow.State, ) => ReactElement)
data-direction
Indicates the direction of the scroll arrow.
data-side
Indicates which side the popup is positioned relative to the trigger.
data-visible
Present when the scroll arrow is visible.
data-starting-style
Present when the scroll arrow is animating in.
data-ending-style
Present when the scroll arrow is animating out.
Separator
A separator element accessible to screen readers.
Renders a <div> element.
orientationOrientation
(default: 'horizontal'
)
Orientation'horizontal'- Name
- Description
- The orientation of the separator. 
- Type
- 'horizontal' | 'vertical' | undefined
- Default
- 'horizontal'
classNamestring | function
string | function- Name
- Description
- CSS class applied to the element, or a function that returns a class based on the component’s state. 
- Type
- string | ((state: Separator.State) => string)
renderReactElement | function
ReactElement | function- Name
- Description
- Allows you to replace the component’s HTML element with a different tag, or compose it with another component. - Accepts a - ReactElementor a function that returns the element to render.
- Type
- | ReactElement | (( props: HTMLProps, state: Separator.State, ) => ReactElement)
Formatting the value
By default, the Select.Value component renders the raw value.
Passing the items prop to Select.Root instead renders the matching label for the rendered value:
const items = [
  { value: null, label: 'Select theme' },
  { value: 'system', label: 'System default' },
  { value: 'light', label: 'Light' },
  { value: 'dark', label: 'Dark' },
];
<Select.Root items={items}>
  <Select.Value />
</Select.Root>const items = {
  null: 'Select theme',
  system: 'System default',
  light: 'Light',
  dark: 'Dark',
};
<Select.Root items={items}>
  <Select.Value />
</Select.Root>A function can also be passed as the children prop of Select.Value to render a formatted value:
const items = {
  monospace: 'Monospace',
  serif: 'Serif',
  'san-serif': 'Sans-serif',
};
<Select.Value>
  {(value: keyof typeof items) => (
    <span style={{ fontFamily: value }}>
      {items[value]}
    </span>
  )}
</Select.Value>Multiple selection
Add the multiple prop to the Select.Root component to allow multiple selections.