Skip to content
Forms

Number Input

Numeric field with steppers, clamping and keyboard control.

Import

tsx
import { NumberInput } from "@cooud-ui/ui";
bash
npx cooud-ui add number-input

Examples

API Reference

Generated from the component's exported types.

NumberInputProps

PropTypeDefaultDescription
value
number | nullControlled value. Pair with `onValueChange`. Use `null` for empty.
defaultValue
number | nullnullInitial value for uncontrolled usage.
onValueChange
(value: number | null) => voidCalled with the new value (or `null` when cleared) on every change.
min
numberMinimum allowed value. The decrement stepper disables at this bound.
max
numberMaximum allowed value. The increment stepper disables at this bound.
step
number1Increment for steppers and Arrow keys. Defaults to `1`.
largeStep
numberLarger increment for PageUp / PageDown. Defaults to `step * 10`.
precision
numberNumber of decimal places to round and display the committed value to.
format
(value: number) => stringCustom formatter for the displayed value when not focused.
disabled
booleanfalseDisables the input and both steppers.
invalid
booleanfalseMarks the field as invalid (forwarded to the underlying Input).
placeholder
stringPlaceholder shown when the field is empty.
className
stringExtra classes for the wrapper element.
inputClassName
stringExtra classes for the underlying input.
aria-label
stringAccessible name for the spinbutton when there is no visible label.
aria-labelledby
stringID of an element labelling the spinbutton.
aria-describedby
stringID of an element describing the spinbutton.
id
stringNative id for the input.
name
stringNative name for the input (form submission).
onBlur
(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.