Select is used as a controlled component with v-model property along with an options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary.
When multiple is enabled, multiple items can be selected. Use checkmark to display a check indicator and a custom #value slot for the label.
An alternative way to highlight the selected option is displaying a checkmark instead.
Multiple selection with checkboxes using multiple and custom #option and #header slots.
Selected items displayed as chips using a custom #value slot in multiple mode.
When showClear is enabled, a clear icon is displayed to clear the value.
Select provides built-in filtering that is enabled by adding the filter property.
Custom content can be placed inside options using the #option slot.
Options can be grouped when a nested data structures is provided.
Customize group headers with custom rendering using the #optiongroup slot.
Combine grouped options, checkbox selection, and a filter to create a rich multi-select experience.
A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information.
IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.
The fluid prop makes the component take up the full width of its container when set to true.
Select provides small and large sizes as alternatives to the base.
Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.
When disabled is present, the element cannot be edited and focused.
The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with form validation libraries.
Customize keyboard and mouse focus behavior with autoOptionFocus, selectOnFocus, and focusOnHover properties.
When editable is present, the input can also be entered with typing.
Both the selected option and the options list can be templated to provide customizated representation. Use the #value slot to customize the selected label display and the #option slot to change the content of the options in the select panel. In addition when grouping is enabled, the #optiongroup slot is available to customize the option groups. The #option and #optiongroup slots receive the option instance, whereas the #value slot receives the selected value itself; when optionValue is set this is the resolved value rather than the option object, so look the option up from your options if you need its other fields.
Loading state is enabled with the loading property.
VirtualScroller is used to render a long list of options efficiently like 100K records in this demo. The configuration is done with virtualScrollerOptions property, refer to the VirtualScroller for more information about the available options as it is used internally by Select.
Select integrates seamlessly with the PrimeVue Forms library.
Value to describe the component can either be provided with aria-labelledby or aria-label props. The select element has a combobox role in addition to aria-haspopup and aria-expanded attributes. If the editable option is enabled aria-autocomplete is also added. The relation between the combobox and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen reader which option to read during keyboard navigation within the popup list.
The popup list has an id that refers to the aria-controls attribute of the combobox element and uses listbox as the role. Each list item has an option role, an id to match the aria-activedescendant of the input element along with aria-label, aria-selected and aria-disabled attributes.
If filtering is enabled, filterInputProps can be defined to give aria-* props to the filter input element.
| Key | Function |
|---|---|
| tab | Moves focus to the select element. |
| space | Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. |
| enter | Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. |
| down arrow | Opens the popup and moves visual focus to the selected option, if there is none then first option receives the focus. |
| up arrow | Opens the popup and moves visual focus to the selected option, if there is none then last option receives the focus. |
| any printable character | Opens the popup and moves focus to the option whose label starts with the characters being typed, if there is none and select is not editable then first option receives the focus. |
| Key | Function |
|---|---|
| tab | Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. |
| shift + tab | Moves focus to the previous focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. |
| enter | Selects the focused option and closes the popup, then moves focus to the select element. |
| space | Selects the focused option and closes the popup, then moves focus to the select element. |
| escape | Closes the popup, then moves focus to the select element. |
| down arrow | Moves focus to the next option, if there is none then visual focus does not change. |
| up arrow | Moves focus to the previous option, if there is none then visual focus does not change. |
| alt + up arrow | Selects the focused option and closes the popup, then moves focus to the select element. |
| left arrow | If the select is editable, removes the visual focus from the current option and moves input cursor to one character left. |
| right arrow | If the select is editable, removes the visual focus from the current option and moves input cursor to one character right. |
| home | If the select is editable, moves input cursor at the end, if not then moves focus to the first option. |
| end | If the select is editable, moves input cursor at the beginning, if not then moves focus to the last option. |
| pageUp | Jumps visual focus to first option. |
| pageDown | Jumps visual focus to last option. |
| any printable character | Moves focus to the option whose label starts with the characters being typed if select is not editable. |
| Key | Function |
|---|---|
| down arrow | Moves focus to the next option, if there is none then visual focus does not change. |
| up arrow | Moves focus to the previous option, if there is none then visual focus does not change. |
| left arrow | Removes the visual focus from the current option and moves input cursor to one character left. |
| right arrow | Removes the visual focus from the current option and moves input cursor to one character right. |
| home | Moves input cursor at the end, if not then moves focus to the first option. |
| end | Moves input cursor at the beginning, if not then moves focus to the last option. |
| enter | Closes the popup and moves focus to the select element. |
| escape | Closes the popup and moves focus to the select element. |
| tab | Moves focus to the next focusable element in the popup. If there is none, the focusable option is selected and the overlay is closed then moves focus to next element in page. |