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';
If true
, the component is disabled. The prop defaults to the value (false
) inherited from the parent FormControl component.
Type:boolean
If 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:boolean
Callback 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) => void
Callback 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:boolean
Default:false
If true
, the input
element is required. The prop defaults to the value (false
) inherited from the parent FormControl component.
Type:boolean
Multiplier applied to step
if the shift key is held while incrementing or decrementing the value. Defaults to 10
.
Type:number
If true
, the input
will indicate an error by setting the aria-invalid
attribute.
Type:boolean
Default:false
Return value from the useFormControlContext
hook.
Type:FormControlState | undefined
Resolver for the decrement button slot's props.
Type:<ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputDecrementButtonSlotProps<ExternalProps>
Resolver for the increment button slot's props.
Type:<ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputIncrementButtonSlotProps<ExternalProps>
Resolver for the input slot's props.
Type:<ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputInputSlotProps<ExternalProps>
Resolver for the root slot's props.
Type:<ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputRootSlotProps<ExternalProps>
If true
, the decrement button will be disabled. e.g. when the value
is already at min
Type:boolean
Default:false
If true
, the increment button will be disabled. e.g. when the value
is already at max
Type:boolean
Default:false