Select API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import Select from '@mui/material/Select';
// or
import { Select } from '@mui/material';
Props
Props of the OutlinedInput component are also available.
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.
Type:
bool
Default:
false
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.
Type:
node
Override or extend the styles applied to the component.
See CSS API below for more details.
Type:
object
Default:
{}
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).
Type:
bool
Default:
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.
Type:
bool
Default:
false
Attributes applied to the input
element. When native
is true
, the attributes are applied on the select
element.
Type:
object
The ID of an element that acts as an additional label. The Select will be labelled by the additional label and the selected value.
Type:
string
If true
, value
must be an array and the menu will support multiple selections.
Type:
bool
Default:
false
Callback fired when a menu item is selected.
Type:
func
Signature:
function(event: SelectChangeEvent, child?: object) => void
event
The event source of the callback. You can pull out the new value by accessingevent.target.value
(any). Warning: This is a generic event, not a change event, unless the change event is caused by browser autofill.child
The react element that was selected whennative
isfalse
(default).
Callback fired when the component requests to be closed. Use it in either controlled (see the open
prop), or uncontrolled mode (to detect when the Select collapses).
Type:
func
Signature:
function(event: object) => void
event
The event source of the callback.
Callback fired when the component requests to be opened. Use it in either controlled (see the open
prop), or uncontrolled mode (to detect when the Select expands).
Type:
func
Signature:
function(event: object) => void
event
The event source of the callback.
If true
, the component is shown. You can only use it when the native
prop is false
(default).
Type:
bool
Render the selected value. You can only use it when the native
prop is false
(default).
Type:
func
Signature:
function(value: any) => ReactNode
value
Thevalue
provided to the component.
The system prop that allows defining system overrides as well as additional CSS styles.
See the `sx` page for more details.
Type:
Array<func | object | bool> | func | object
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.
Type:
'' | any
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.
CSS
The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.
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.