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';
Learn about the difference by reading this guide on minimizing bundle size.
Name | Type | Default | Description |
---|---|---|---|
componentName | string | 'useNumberInput' | The name of the component using useNumberInput. For debugging purposes. |
defaultValue | number | null | - | The default value. Use when the component is not controlled. |
disabled | boolean | - | If |
error | boolean | - | If |
inputId | string | - | The |
inputRef | React.Ref<HTMLInputElement> | - | The ref of the input element. |
max | number | - | The maximum value. |
min | number | - | The minimum value. |
onBlur | (event?: React.FocusEvent<HTMLInputElement>) => void | - | |
onChange | (event: React.FocusEvent<HTMLInputElement> | React.PointerEvent | React.KeyboardEvent, value: number | null) => void | - | Callback fired after the value is clamped and changes - when the |
onClick | React.MouseEventHandler | - | |
onFocus | React.FocusEventHandler | - | |
onInputChange | React.ChangeEventHandler<HTMLInputElement> | - | Callback fired when the |
readOnly | boolean | false | If |
required | boolean | - | If |
shiftMultiplier | number | - | Multiplier applied to |
step | number | - | The amount that the value changes on each increment or decrement. |
value | number | null | null | The current value. Use when the component is controlled. |
Name | Type | Default | Description |
---|---|---|---|
disabled | boolean | false | If |
error | boolean | false | If |
focused | boolean | false | If |
formControlContext | FormControlState | undefined | - | Return value from the |
getDecrementButtonProps | <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputDecrementButtonSlotProps<ExternalProps> | - | Resolver for the decrement button slot's props. |
getIncrementButtonProps | <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputIncrementButtonSlotProps<ExternalProps> | - | Resolver for the increment button slot's props. |
getInputProps | <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputInputSlotProps<ExternalProps> | - | Resolver for the input slot's props. |
getRootProps | <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseNumberInputRootSlotProps<ExternalProps> | - | Resolver for the root slot's props. |
inputValue | string | - | The dirty |
isDecrementDisabled | boolean | false | If |
isIncrementDisabled | boolean | false | If |
required | boolean | false | If |
value | number | null | - | The clamped |