0 Tk

select

Import

import Select from '@mui/material/Select';
// or
import { Select } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.

Props of the OutlinedInput component are also available.

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 classes API below for more details.
defaultOpen bool false If true, the component is initially open. Use when the component open state is not controlled (i.e. the open prop is not defined). You can only use it when the native prop is false (default).
defaultValue any - The default value. Use when the component is not controlled.
displayEmpty bool false If true, a value is displayed even if no items are selected.
In order to display a meaningful value, a function can be passed to the renderValue prop which returns the value to be displayed when no items are selected.
⚠️ When using this prop, make sure the label doesn’t overlap with the empty displayed value. The label should either be hidden or forced to a shrunk state.
IconComponent elementType ArrowDropDownIcon The icon that displays the arrow.
id string - The id of the wrapper element or the select element when native.
input element - 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.
label node - See OutlinedInput#label
labelId string - The ID of an element that acts as an additional label. The Select will be labelled by the additional label and the selected value.
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 uses a native select element.
onChange func - Callback fired when a menu item is selected.
Signature: function(event: SelectChangeEvent, child?: object) => void
- event The event source of the callback.
- child The react element that was selected when native is false (default).
onClose func - Callback fired when the component requests to be closed.
Signature: function(event: object) => void
- event The event source of the callback.
onOpen func - Callback fired when the component requests to be opened.
Signature: function(event: object) => void
- event The event source of the callback.
open bool - If true, the component is shown. 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) => ReactNode
- value The value provided to the component.
SelectDisplayProps object - Props applied to the clickable div element.
sx Array<func | object | bool> | func | object - The system prop that allows defining system overrides as well as additional CSS styles.
See the sx page for more details.
value ‘’ | any - The input value. Providing an empty string will select no options. Set to an empty string '' if you don’t want any of the available options to be selected.
If the value is an object it must have reference equality with the option in order to be selected. If the value is not an object, the string representation must match with the string representation of the option in order to be selected.
variant ‘filled’ | ‘outlined’ | ‘standard’ ‘outlined’ The variant to use.

The ref is forwarded to the root element.

Inheritance

While not explicitly documented above, the props of the OutlinedInput component are also available in Select. You can take advantage of this to target nested components.

Theme default props

You can use MuiSelect to change the default props of this component with the theme.

These class names are useful for styling with CSS. They are applied to the component’s slots when specific states are triggered.

Class name Rule name Description
.Mui-disabled State class applied to the select component disabled class.
.Mui-error State class applied to the root element if error={true}.
.Mui-focused Styles applied to the select component if it is focused.
.MuiSelect-filled filled Styles applied to the select component if variant="filled".
.MuiSelect-icon icon Styles applied to the icon component.
.MuiSelect-iconFilled iconFilled Styles applied to the icon component if variant="filled".
.MuiSelect-iconOpen iconOpen Styles applied to the icon component if the popup is open.
.MuiSelect-iconOutlined iconOutlined Styles applied to the icon component if variant="outlined".
.MuiSelect-iconStandard iconStandard Styles applied to the icon component if variant="standard".
.MuiSelect-multiple multiple Styles applied to the select component if multiple={true}.
.MuiSelect-nativeInput nativeInput Styles applied to the underlying native input component.
.MuiSelect-outlined outlined Styles applied to the select component if variant="outlined".
.MuiSelect-root root Styles applied to the root element.
.MuiSelect-select select Styles applied to the select component select class.
.MuiSelect-standard standard Styles applied to the select component if variant="standard".

You can override the style of the component using one of these customization options:

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.