--- productId: joy-ui title: React Select component components: Select, Option githubLabel: 'scope: select' waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ --- # Select

Select components are used for collecting user-provided information from a list of options.

{{"component": "@mui/docs/ComponentLinkHeader"}} ## Introduction The `Select` component is used to trigger a popup that displays a list of `Option` components. {{"demo": "SelectUsage.js", "hideToolbar": true, "bg": "gradient"}} ## Component After [installation](/joy-ui/getting-started/installation/), you can start building with this component using the following basic elements: ```jsx import Select from '@mui/joy/Select'; import Option from '@mui/joy/Option'; export default function SelectBasic() { return ( ); } ``` ### Basic usage The `Select` component is similar to the native HTML's ` ``` ### Decorators Use the `startDecorator` and/or `endDecorator` props to add supporting icons or elements to the select. {{"demo": "SelectDecorators.js"}} If you have interactive elements as the select's decorators, call `stopPropagation()` from the mouse down event to prevent the popup from being opened. ```jsx { // don't open the popup when clicking on this button event.stopPropagation(); }} onClick={() => { // click handler goes here } >... ``` ### Indicator To change the default indicator, use the `indicator` prop with either any React element (including string) or `null` as value (to remove the indicator completely). {{"demo": "SelectIndicator.js"}} To apply the indicator to all instances of the select component, customize the `indicator` prop directly in the theme: ```js import { extendTheme, CssVarsProvider } from '@mui/joy/styles'; import Select from '@mui/joy/Select'; const theme = extendTheme({ components: { JoySelect: { defaultProps: { indicator: '↕', }, }, }, }); const App = () => ( ); ``` ### Multiple selections Set the `multiple` prop to let your users select multiple options from the list. In contrast with single-selection mode, the options popup doesn't close after an item is selected, which enables users to continue choosing more options. Note that in multiple selection mode, the `value` prop (and `defaultValue`) is an array. {{"demo": "SelectMultiple.js"}} #### Selected value appearance Use the `renderValue` prop to customize the display of the selected options. {{"demo": "SelectMultipleAppearance.js"}} #### Form submission The `Select` component supports `name` and `required` props that will be used when submitting the form. {{"demo": "SelectMultipleFormSubmission.js"}} ### Listbox #### Maximum height To change the listbox's maximum height, use `slotProps` prop to target listbox slot: ```jsx ``` #### Minimum width By default, the listbox's width is equal to Select's button or the maximum content of its children. You can control the minimum width by using `slotProps` prop to target listbox slot. {{"demo": "SelectMinWidth.js"}} :::success To control the placement of the listbox, use `placement`: ```js ``` ::: ## Accessibility In order for the select to be accessible, **it should be linked to a label**. The `FormControl` automatically generates a unique id that links the select with the `FormLabel` component: {{"demo": "SelectFieldDemo.js"}} Alternatively, you can do it manually by targeting the button slot: ```jsx ``` ## Common examples ### Clear action Use the `IconButton` component as a decorator to the `Select` to add a clear action. The `Select` will set the focus-visible state back to the select button after the select value is cleared, ensuring a great keyboard-navigation experience. {{"demo": "SelectClearable.js"}} ### Selected value appearance The select will display the value of the `label` prop when the option is selected. The value can be `string`, `number`, or any valid React element. {{"demo": "SelectCustomValueAppearance.js"}} ## Debugging To keep the listbox open for inspecting elements, enable the `Emulate a focused page` option from the [Chrome DevTool Rendering](https://developer.chrome.com/docs/devtools/rendering/apply-effects/#emulate-a-focused-page) tab. You can also access this option by using [command menu and search for it](https://developer.chrome.com/docs/devtools/command-menu/).