跳转到内容

NativeSelect API

API documentation for the React NativeSelect component. Learn about the available props, and the CSS API.

Import

import NativeSelect from '@material-ui/core/NativeSelect';
// 或
import { NativeSelect } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

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

Component name

The name MuiNativeSelect can be used when providing default props or style overrides in the theme.

属性

名称类型默认值描述
childrennodeThe option elements to populate the select with. Can be some <option> elements.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
IconComponentelementTypeArrowDropDownIconThe icon that displays the arrow.
inputelement<Input />An Input element; does not have to be a material-ui specific Input.
inputPropsobjectAttributes applied to the select element.
onChangefuncCallback fired when a menu item is selected.

Signature:
function(event: object) => void
event: The event source of the callback. You can pull out the new value by accessing event.target.value (string).
valueanyThe input value. The DOM API casts this to a string.
variant'filled'
| 'outlined'
| 'standard'
The variant to use.

ref 则会被传递到根元素中。
Any other props supplied will be provided to the root element (Input).

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.

CSS

Rule nameGlobal class描述
root.MuiNativeSelect-rootStyles applied to the select component `root` class.
select.MuiNativeSelect-selectStyles applied to the select component `select` class.
filled.MuiNativeSelect-filledStyles applied to the select component if variant="filled".
outlined.MuiNativeSelect-outlinedStyles applied to the select component if variant="outlined".
selectMenu.MuiNativeSelect-selectMenuStyles applied to the select component `selectMenu` class.
disabled.Mui-disabledPseudo-class applied to the select component `disabled` class.
icon.MuiNativeSelect-iconStyles applied to the icon component.
iconOpen.MuiNativeSelect-iconOpenStyles applied to the icon component if the popup is open.
iconFilled.MuiNativeSelect-iconFilledStyles applied to the icon component if variant="filled".
iconOutlined.MuiNativeSelect-iconOutlinedStyles applied to the icon component if variant="outlined".
nativeInput.MuiNativeSelect-nativeInputStyles applied to the underlying native input component.

You can override the style of the component using one of these customization options: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos