# Select An unstyled select dropdown component with keyboard navigation, filtering, and single or multiple selection. ## Features - Compound component API with sub-components: `Root`, `Trigger`, `Value`, `Indicator`, `Clear`, `Portal`, `Positioner`, `Popup`, `List`, `Option`, `OptionIndicator`, `Filter`, `Arrow`, `Header`, `Footer`, `Empty` - Single and multiple selection with keyboard focus cycling - Built-in filter input integration for searchable dropdowns - Option grouping with group header rendering ## Usage ```tsx import { Select } from 'primereact/select'; ``` ```tsx ``` ## Behavior ### Motion Animation ```tsx ... ``` See [Motion](/docs/primitive/components/motion) for animation phases, CSS variables, and hide strategies. ### Polymorphic Rendering Use `as` on any sub-component to change the rendered HTML element. ```tsx ... ``` ### Render Function Children `Select.List` accepts a render function as children, providing access to the component instance for custom option rendering. ```tsx {(instance) => instance.options?.map((option, index) => ( {instance.listbox?.getOptionLabel(option)} )) } ``` ## Pass Through ## API ### SelectRoot | Attribute | Value | | ------------ | ---------- | | `data-scope` | `"select"` | | `data-part` | `"root"` | | Label | Type | Description | |:------|:------|:------| | root | SelectRootPassThroughType> | Used to pass attributes to the root's DOM element. | | trigger | SelectRootPassThroughType> | Used to pass attributes to the trigger's DOM element. | | value | SelectRootPassThroughType> | Used to pass attributes to the value's DOM element. | | clearIcon | SelectRootPassThroughType> | Used to pass attributes to the clear icon's DOM element. | | icon | SelectRootPassThroughType> | Used to pass attributes to the icon's DOM element. | | positioner | SelectRootPassThroughType> | Used to pass attributes to the positioner's DOM element. | | panel | SelectRootPassThroughType> | Used to pass attributes to the panel's DOM element. | | filter | SelectRootPassThroughType> | Used to pass attributes to the filter's DOM element. | | list | SelectRootPassThroughType> | Used to pass attributes to the list's DOM element. | | options | SelectRootPassThroughType> | Used to pass attributes to the options' DOM element. | | option | SelectRootPassThroughType> | Used to pass attributes to the option's DOM element. | | selection | SelectRootPassThroughType> | Used to pass attributes to the selection's DOM element. | | header | SelectRootPassThroughType> | Used to pass attributes to the header's DOM element. | | footer | SelectRootPassThroughType> | Used to pass attributes to the footer's DOM element. | | empty | SelectRootPassThroughType> | Used to pass attributes to the empty's DOM element. | ### SelectTrigger | Attribute | Value | | ---------------------- | -------------------------- | | `data-scope` | `"select"` | | `data-part` | `"trigger"` | | `data-positioner-open` | Present when popup is open | | Label | Type | Description | |:------|:------|:------| | root | SelectTriggerPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectValue | Label | Type | Description | |:------|:------|:------| | root | SelectValuePassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectIndicator | Attribute | Value | | ------------- | ---------------------------- | | `data-scope` | `"select"` | | `data-part` | `"indicator"` | | `data-open` | Present when popup is open | | `data-closed` | Present when popup is closed | | Label | Type | Description | |:------|:------|:------| | root | SelectIndicatorPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectClear | Attribute | Value | | ------------ | ---------- | | `data-scope` | `"select"` | | `data-part` | `"clear"` | | Label | Type | Description | |:------|:------|:------| | root | SelectClearPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectPortal | Label | Type | Description | |:------|:------|:------| | root | SelectPortalPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectPositioner | Attribute | Value | | ------------ | --------------------------------------------------------- | | `data-side` | `"top"` \| `"bottom"` \| `"left"` \| `"right"`, placement | | `data-align` | `"start"` \| `"center"` \| `"end"`, alignment | **CSS Custom Properties** The positioner element exposes CSS custom properties for layout and transform control. | CSS Variable | Description | | ------------------------------ | ---------------------------------------- | | `--px-available-height` | Available vertical space in pixels | | `--px-available-width` | Available horizontal space in pixels | | `--px-transform-origin` | Computed transform origin for animations | | `--px-positioner-anchor-width` | Width of the anchor/trigger element | | Label | Type | Description | |:------|:------|:------| | root | SelectPositionerPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectPopup | Attribute | Value | | ------------ | -------------------------- | | `data-scope` | `"select"` | | `data-part` | `"popup"` | | `data-open` | Present when popup is open | | Label | Type | Description | |:------|:------|:------| | root | SelectPopupPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectFilter | Attribute | Value | | ------------ | ---------- | | `data-scope` | `"select"` | | `data-part` | `"filter"` | | Label | Type | Description | |:------|:------|:------| | root | SelectFilterPassThroughType> | Used to pass attributes to the root's DOM element. | | input | SelectFilterPassThroughType> | Used to pass attributes to the input's DOM element. | ### SelectList | Attribute | Value | | ------------ | ---------- | | `data-scope` | `"select"` | | `data-part` | `"list"` | | Label | Type | Description | |:------|:------|:------| | root | SelectListPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectOption | Attribute | Value | | ----------------- | ----------------------- | | `data-selected` | Present when selected | | `data-unselected` | Present when unselected | | `data-focused` | Present when focused | | `data-disabled` | Present when disabled | | Label | Type | Description | |:------|:------|:------| | root | SelectOptionPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectOptionIndicator | Attribute | Value | | ----------------- | ----------------------- | | `data-selected` | Present when selected | | `data-unselected` | Present when unselected | | Label | Type | Description | |:------|:------|:------| | root | SelectOptionIndicatorPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectHeader | Label | Type | Description | |:------|:------|:------| | root | SelectHeaderPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectFooter | Label | Type | Description | |:------|:------|:------| | root | SelectFooterPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectEmpty | Label | Type | Description | |:------|:------|:------| | root | SelectEmptyPassThroughType> | Used to pass attributes to the root's DOM element. | ### SelectArrow | Attribute | Value | | ------------ | --------------------------------------------------------- | | `data-side` | `"top"` \| `"bottom"` \| `"left"` \| `"right"`, placement | | `data-align` | `"start"` \| `"center"` \| `"end"`, alignment | **CSS Custom Properties** The arrow element exposes CSS custom properties for dynamic positioning: | CSS Variable | Description | | ------------------------ | ------------------------------ | | `--px-placer-arrow-x` | Horizontal offset of arrow | | `--px-placer-arrow-y` | Vertical offset of arrow | | `--px-placer-arrow-left` | Left position of arrow element | | `--px-placer-arrow-top` | Top position of arrow element | | Label | Type | Description | |:------|:------|:------| | root | SelectArrowPassThroughType> | Used to pass attributes to the root's DOM element. | ## Accessibility ### Screen Reader `Select.Root` uses a combobox pattern. The trigger has `role="combobox"` with `aria-expanded` reflecting the popup visibility and `aria-controls` linking to the listbox. The `aria-activedescendant` attribute instructs screen readers which option to read during keyboard navigation. Options have `role="option"` with `aria-selected` to indicate the current selection. The clear button has an `aria-label` for screen reader accessibility. Decorative elements like the indicator are hidden from screen readers with `aria-hidden`. Provide an accessible name with `aria-label`, `aria-labelledby`, or an associated label element. ### Keyboard Support | Key | Function | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `tab` | Moves focus to the select trigger. | | `enter` | Opens the popup when focused, selects the focused option when open. | | `space` | Opens the popup when focused, selects the focused option when open. | | `escape` | Closes the popup. | | `arrow down` | Opens the popup or moves focus to the next option. | | `arrow up` | Opens the popup or moves focus to the previous option. | | `home` | Moves focus to the first option. | | `end` | Moves focus to the last option. | | `any printable character` | When the popup is open, moves focus to the filter and types the character into it. Without a filter, moves focus to the option whose label starts with the typed characters. |