Select
The Select components let you create lists of options for users to choose from.
useOption API
Import
import { useOption } from '@mui/base/useOption';
// or
import { useOption } from '@mui/base';Parameters
Return value
Type:
<Other extends EventHandlers>(otherHandlers?: Other) => UseOptionRootSlotProps<Other>useSelect API
Import
import { useSelect } from '@mui/base/useSelect';
// or
import { useSelect } from '@mui/base';Parameters
A function used to determine if two options' values are equal.
By default, reference equality is used.
There is a performance impact when using the areOptionsEqual prop (proportional to the number of options).
Therefore, it's recommented to use the default reference equality comparison whenever possible.
Type:
(a: OptionValue, b: OptionValue) => booleanThe ref of the trigger button element.
Type:
React.Ref<Element>The default selected value. Use when the component is not controlled.
Type:
SelectValue<OptionValue, Multiple>A function used to convert the option label to a string. This is useful when labels are elements and need to be converted to plain text to enable keyboard navigation with character keys.
Type:
(option: SelectOption<OptionValue>) => stringDefault:
defaultOptionStringifierIf true, the end user can select multiple values.
This affects the type of the value, defaultValue, and onChange props.
Type:
MultipleDefault:
falseCallback fired when an option is selected.
Type:
(event: React.MouseEvent | React.KeyboardEvent | React.FocusEvent | null, value: SelectValue<OptionValue, Multiple>) => voidCallback fired when an option is highlighted.
Type:
(event: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element> | React.FocusEvent<Element, Element> | null, highlighted: OptionValue | null) => voidControls the open state of the select's listbox.
This is the controlled equivalent of the defaultOpen prop.
Type:
booleanAn alternative way to specify the options. If this parameter is set, options defined as JSX children are ignored.
Type:
SelectOptionDefinition<OptionValue>[]Return value
If true, the trigger button is active (pressed).
Type:
booleanIf true, the trigger button has a visible focus.
Type:
booleanRef to the button slot DOM node.
Type:
React.RefCallback<Element> | nullAction dispatcher for the select component. Allows to programmatically control the select.
Type:
(action: ListAction<Value> | SelectAction) => voidResolver for the button slot's props.
Type:
<OtherHandlers extends EventHandlers = {}>(otherHandlers?: OtherHandlers) => UseSelectButtonSlotProps<OtherHandlers>Resolver for the listbox slot's props.
Type:
<OtherHandlers extends EventHandlers = {}>(otherHandlers?: OtherHandlers) => UseSelectListboxSlotProps<OtherHandlers>A function that returns the metadata of an option with a given value.
Type:
(optionValue: Value) => SelectOption<Value> | undefined