Skip to main content

InputNumber

Numeric-only input with range clamping, step and precision control, stepped via buttons or arrow keys.

Basic usage​

Range / precision / step / sizes
Current value: 1
Range 1 - 10

The first row is the controlled usage (stepping via buttons or arrow keys; manual input commits on blur or Enter); the second row clamps the value into the min / max range; the third row fixes decimals with precision, snaps input onto the step grid with stepStrictly (multiples of the step), and disables with disabled; the fourth row shows the three sizes and controls={false} to hide the control buttons.

import { useState } from 'react'
import { LhInputNumber } from '@lh-ui/react'

export default function Demo() {
const [value, setValue] = useState<number | null>(1)

return <LhInputNumber value={value} onChange={setValue} min={1} max={10} />
}

InputNumber Props​

PropDescriptionTypeOptionsDefault
valueControlled value (null means empty)number | null——
defaultValueUncontrolled default valuenumber | null—null
minMinimum valuenumber—-Infinity
maxMaximum valuenumber—Infinity
stepStep (its absolute value is used)number—1
stepStrictlySnap input onto the step grid based on minboolean—false
precisionNumeric precision (decimal places)number——
disabledWhether to disableboolean—false
sizeSize'large' | 'medium' | 'small'—'medium'
controlsWhether to show the increment / decrement buttonsboolean—true
placeholderPlaceholderstring—''
nameNative name attributestring——
sxShorthand layout propsSxProps——

InputNumber events​

EventDescriptionCallback signatureVue equivalent
onChangeValue change (fired by both stepping and committing; null when committed as empty)(value: number | null) => void@update:modelValue / @change
Keyboard and accessibility

The input carries role="spinbutton" with the aria-valuemin / aria-valuemax / aria-valuenow value semantics. Press ↑ / ↓ while focused to step by step; manual input commits on blur or Enter — an empty string clears to null, invalid numbers fall back to the previous value, and valid values go through precision rounding and min / max clamping, then snap onto the step grid (rounded) when stepStrictly is on.

ref​

forwardRef<HTMLInputElement> — the focusable native input element.

Styles​

import '@lh-ui/react/style/input-number'