Select API
The API documentation of the Select React component. Learn more about the props and the CSS customization points.
import { Select } from '@material-ui/core';
Props
Name | Type | Default | Description |
---|---|---|---|
autoWidth | bool | false | If true, the width of the popover will automatically be set according to the items inside the menu, otherwise it will be at least the width of the select input. |
children | node | The option elements to populate the select with. Can be some MenuItem when native is false and option when native is true.⚠️The MenuItem elements must be direct descendants when native is false. |
|
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
displayEmpty | bool | false | If true , a value is displayed even if no items are selected.In order to display a meaningful value, a function should be passed to the renderValue prop which returns the value to be displayed when no items are selected. You can only use it when the native prop is false (default). |
IconComponent | elementType | ArrowDropDownIcon | The icon that displays the arrow. |
input | element | <Input /> | An Input element; does not have to be a material-ui specific Input . |
inputProps | object | Attributes applied to the input element. When native is true , the attributes are applied on the select element. |
|
MenuProps | object | Props applied to the Menu element. |
|
multiple | bool | false | If true, value must be an array and the menu will support multiple selections. |
native | bool | false | If true , the component will be using a native select element. |
onChange | func | Callback function fired when a menu item is selected. Signature: function(event: object, child?: object) => void event: The event source of the callback. You can pull out the new value by accessing event.target.value .child: The react element that was selected when native is false (default). |
|
onClose | func | Callback fired when the component requests to be closed. Use in controlled mode (see open). Signature: function(event: object) => void event: The event source of the callback |
|
onOpen | func | Callback fired when the component requests to be opened. Use in controlled mode (see open). Signature: function(event: object) => void event: The event source of the callback |
|
open | bool | Control select open state. You can only use it when the native prop is false (default). |
|
renderValue | func | Render the selected value. You can only use it when the native prop is false (default).Signature: function(value: any) => ReactElement value: The value provided to the component. |
|
SelectDisplayProps | object | Props applied to the clickable div element. | |
value | any | The input value. This prop is required when the native prop is false (default). |
|
variant | 'standard' | 'outlined' | 'filled' |
The variant to use. |
The ref
is forwarded to the root element.
Any other props supplied will be provided to the root element (Input).
CSS
- Style sheet name:
MuiSelect
. - Style sheet details:
Rule name | Global class | Description |
---|---|---|
root | MuiSelect-root | Styles applied to the select component root class. |
select | MuiSelect-select | Styles applied to the select component select class. |
filled | MuiSelect-filled | Styles applied to the select component if variant="filled" . |
outlined | MuiSelect-outlined | Styles applied to the select component if variant="outlined" . |
selectMenu | MuiSelect-selectMenu | Styles applied to the select component selectMenu class. |
disabled | Mui-disabled | Pseudo-class applied to the select component disabled class. |
icon | MuiSelect-icon | Styles applied to the select component icon class. |
You can override the style of the component thanks to one of these customization points:
- With a rule name of the
classes
object prop. - With a global class name.
- With a theme and an
overrides
property.
If that's not sufficient, you can check the implementation of the component for more detail.
Inheritance
The props of the Input component are also available. You can take advantage of this behavior to target nested components.
Notes
The component can cause issues in StrictMode.