[go: up one dir, main page]

Skip to content

NativeSelect API

API reference docs for the React NativeSelect component. Learn about the props, CSS, and other APIs of this exported module.

DemosImport
import NativeSelect from '@mui/material/NativeSelect';
// or
import { NativeSelect } from '@mui/material';

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



An alternative to <Select native /> with a much smaller bundle size footprint.

Props

Props of the Input component are also available.

NameTypeDefaultDescription
childrennode-

The option elements to populate the select with. Can be some <option> elements.

classesobject{}

Override or extend the styles applied to the component.

See CSS classes API below for more details.

IconComponentelementTypeArrowDropDownIcon

The icon that displays the arrow.

inputelement<Input />

An Input element; does not have to be a material-ui specific Input.

inputPropsobject-

Attributes applied to the select element.

onChangefunc-

Callback fired when a menu item is selected.

Signature:function(event: React.ChangeEvent) => void
  • event The event source of the callback. You can pull out the new value by accessing event.target.value (string).
sxArray<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.

valueany-

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 in NativeSelect. You can take advantage of this to target nested components.

Theme default props

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

CSS classes

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

Class nameRule nameDescription
.Mui-disabledState class applied to the select component disabled class.
.Mui-errorState class applied to the select component error class.
.MuiNativeSelect-filledfilledStyles applied to the select component if variant="filled".
.MuiNativeSelect-iconiconStyles applied to the icon component.
.MuiNativeSelect-iconFillediconFilledStyles applied to the icon component if variant="filled".
.MuiNativeSelect-iconOpeniconOpenStyles applied to the icon component if the popup is open.
.MuiNativeSelect-iconOutlinediconOutlinedStyles applied to the icon component if variant="outlined".
.MuiNativeSelect-iconStandardiconStandardStyles applied to the icon component if variant="standard".
.MuiNativeSelect-multiplemultipleStyles applied to the select component if multiple={true}.
.MuiNativeSelect-nativeInputnativeInputStyles applied to the underlying native input component.
.MuiNativeSelect-outlinedoutlinedStyles applied to the select component if variant="outlined".
.MuiNativeSelect-rootrootStyles applied to the root element.
.MuiNativeSelect-selectselectStyles applied to the select component select class.
.MuiNativeSelect-standardstandardStyles 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.