Number Input
The Number Input component provides users with a field for integer values, and buttons to increment or decrement the value.
useNumberInput API
Import
import { unstable_useNumberInput as useNumberInput } from '@mui/base/unstable_useNumberInput';
// or
import { unstable_useNumberInput as useNumberInput } from '@mui/base';Parameters
If true, the component is disabled.
The prop defaults to the value (false) inherited from the parent FormControl component.
Type:
booleanIf true, the input will indicate an error by setting the aria-invalid attribute.
The prop defaults to the value (false) inherited from the parent FormControl component.
Type:
booleanCallback fired after the value is clamped and changes - when the input is blurred or when
the stepper buttons are triggered.
Called with undefined when the value is unset.
Type:
(event: React.FocusEvent<HTMLInputElement> | React.PointerEvent | React.KeyboardEvent, value: number | undefined) => voidCallback fired when the input value changes after each keypress, before clamping is applied.
Note that event.target.value may contain values that fall outside of min and max or
are otherwise "invalid".
Type:
React.ChangeEventHandler<HTMLInputElement>If true, the input element becomes read-only. The stepper buttons remain active,
with the addition that they are now keyboard focusable.
Type:
booleanDefault:
falseIf true, the input element is required.
The prop defaults to the value (false) inherited from the parent FormControl component.
Type:
booleanMultiplier applied to step if the shift key is held while incrementing
or decrementing the value. Defaults to 10.
Type:
numberReturn value
If true, the input will indicate an error by setting the aria-invalid attribute.
Type:
booleanDefault:
falseReturn value from the useFormControlContext hook.
Type:
FormControlState | undefinedResolver for the decrement button slot's props.
Type:
<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseNumberInputDecrementButtonSlotProps<TOther>Resolver for the increment button slot's props.
Type:
<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseNumberInputIncrementButtonSlotProps<TOther>Resolver for the input slot's props.
Type:
<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseNumberInputInputSlotProps<TOther>Resolver for the root slot's props.
Type:
<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseNumberInputRootSlotProps<TOther>If true, the decrement button will be disabled.
e.g. when the value is already at min
Type:
booleanDefault:
falseIf true, the increment button will be disabled.
e.g. when the value is already at max
Type:
booleanDefault:
false