NativeSelect API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import NativeSelect from '@mui/material/NativeSelect';
// or
import { NativeSelect } from '@mui/material';
An alternative to <Select native />
with a much smaller bundle size footprint.
Props
Props of the Input component are also available.
Name | Type | Default | Description |
---|---|---|---|
children | node | The option elements to populate the select with. Can be some <option> elements. | |
classes | object | {} | Override or extend the styles applied to the component. See CSS API below for more details. |
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 select element. | |
onChange | func | Callback fired when a menu item is selected. Signature: function(event: React.ChangeEvent<HTMLSelectElement>) => void event: The event source of the callback. You can pull out the new value by accessing event.target.value (string). | |
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. The DOM API casts this to a string. | |
variant | 'filled' | 'outlined' | 'standard' | The variant to use. |
The
ref
is forwarded to the root element.Inheritance
While not explicitly documented above, the props of the Input component are also available on NativeSelect. You can take advantage of this to target nested components.Theme default props
You can useMuiNativeSelect
to change the default props of this component with the theme.CSS
The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.
Rule name | Global class | Description |
---|---|---|
root | .MuiNativeSelect-root | Styles applied to the root element. |
select | .MuiNativeSelect-select | Styles applied to the select component select class. |
multiple | .MuiNativeSelect-multiple | Styles applied to the select component if multiple={true} . |
filled | .MuiNativeSelect-filled | Styles applied to the select component if variant="filled" . |
outlined | .MuiNativeSelect-outlined | Styles applied to the select component if variant="outlined" . |
standard | .MuiNativeSelect-standard | Styles applied to the select component if variant="standard" . |
disabled STATE | .Mui-disabled | State class applied to the select component disabled class. |
icon | .MuiNativeSelect-icon | Styles applied to the icon component. |
iconOpen | .MuiNativeSelect-iconOpen | Styles applied to the icon component if the popup is open. |
iconFilled | .MuiNativeSelect-iconFilled | Styles applied to the icon component if variant="filled" . |
iconOutlined | .MuiNativeSelect-iconOutlined | Styles applied to the icon component if variant="outlined" . |
iconStandard | .MuiNativeSelect-iconStandard | Styles applied to the icon component if variant="standard" . |
nativeInput | .MuiNativeSelect-nativeInput | Styles applied to the underlying native input component. |
error STATE | .Mui-error | State class applied to the select component error class. |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.