Skip to content

NumberInput

Numeric input field with optional min/max bounds and step control.

function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />

Wheel disabled (default): scrolling over the focused input scrolls this panel.

Wheel enabled: scrolling over the focused input changes its value.

function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<div className={wheelStoryStyles.grid}>
<div className={wheelStoryStyles.panel}>
<p className={wheelStoryStyles.text}>
Wheel disabled (default): scrolling over the focused input scrolls
this panel.
</p>
<div className={wheelStoryStyles.scrollArea}>
<div className={wheelStoryStyles.spacer} />
<ControlledNumberInput label="Wheel disabled" value={2} />
<div className={wheelStoryStyles.spacer} />
</div>
</div>
<div className={wheelStoryStyles.panel}>
<p className={wheelStoryStyles.text}>
Wheel enabled: scrolling over the focused input changes its value.
</p>
<div className={wheelStoryStyles.scrollArea}>
<div className={wheelStoryStyles.spacer} />
<ControlledNumberInput
isWheelEnabled
label="Wheel enabled"
value={2}
/>
<div className={wheelStoryStyles.spacer} />
</div>
</div>
</div>
GB
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<ControlledNumberInput label="Small" size="sm" value={10} />
<ControlledNumberInput label="Medium" size="md" value={20} />
<ControlledNumberInput label="Large" size="lg" value={30} />
</div>
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
Value is unusually high
Value is valid
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<ControlledNumberInput
label="Error"
status={{message: 'Value is out of range', type: 'error'}}
value={999}
/>
<ControlledNumberInput
label="Warning"
status={{message: 'Value is unusually high', type: 'warning'}}
value={95}
/>
<ControlledNumberInput
label="Success"
status={{message: 'Value is valid', type: 'success'}}
value={50}
/>
</div>
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
Enter a value between 1 and 100
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
USD
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />
function ControlledNumberInput({
value: initialValue = null,
...args
}: ControlledNumberInputProps): React.JSX.Element {
const [value, setValue] = useState<number | null>(initialValue);
return (
<NumberInput
{...(args as NumberInputProps)}
onChange={setValue}
value={value}
/>
);
}
<ControlledNumberInput {...args} />

Numeric input field with optional min/max bounds and step control.

When isOptional: false, isRequired: false, hasClear: true

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptionalfalse
isRequiredfalse
hasClear*trueWhether to show a clear button.
onChange*(value: number | null) => voidCalled when the numeric value changes or is cleared.

When isOptional: true, isRequired: false, hasClear: true

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptional*true
isRequiredfalse
hasClear*trueWhether to show a clear button.
onChange*(value: number | null) => voidCalled when the numeric value changes or is cleared.

When isOptional: false, isRequired: true, hasClear: true

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptionalfalse
isRequired*true
hasClear*trueWhether to show a clear button.
onChange*(value: number | null) => voidCalled when the numeric value changes or is cleared.

When isOptional: false, isRequired: false, hasClear: false

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptionalfalse
isRequiredfalse
hasClearfalseWhether to show a clear button.
onChange*(value: number) => voidCalled when the numeric value changes.

When isOptional: true, isRequired: false, hasClear: false

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptional*true
isRequiredfalse
hasClearfalseWhether to show a clear button.
onChange*(value: number) => voidCalled when the numeric value changes.

When isOptional: false, isRequired: true, hasClear: false

PropTypeDefaultDescription
autoCompletestringHTML autocomplete attribute value.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text displayed below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
isIntegerOnlybooleanfalseWhether to restrict input to integer values only.
isWheelEnabledbooleanfalseWhether scrolling the mouse wheel over the focused input changes its value.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is in a loading state.
label*stringField label.
labelIconIconComponentIcon rendered beside the label.
labelTooltipReactNodeTooltip content shown next to the label.
maxnumber | nullMaximum allowed value.
minnumber | nullMinimum allowed value.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input receives focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"'md'Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusValidation status displayed below the input.
stepnumber | nullStep increment for the number input.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
unitsstring | nullUnit label displayed after the input value.
value*number | nullControlled numeric value.
isOptionalfalse
isRequired*true
hasClearfalseWhether to show a clear button.
onChange*(value: number) => voidCalled when the numeric value changes.