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
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | null | — | Controlled value. Pair with `onValueChange`. Use `null` for empty. |
defaultValue | number | null | null | Initial value for uncontrolled usage. |
onValueChange | (value: number | null) => void | — | Called with the new value (or `null` when cleared) on every change. |
min | number | — | Minimum allowed value. The decrement stepper disables at this bound. |
max | number | — | Maximum allowed value. The increment stepper disables at this bound. |
step | number | 1 | Increment for steppers and Arrow keys. Defaults to `1`. |
largeStep | number | — | Larger increment for PageUp / PageDown. Defaults to `step * 10`. |
precision | number | — | Number of decimal places to round and display the committed value to. |
format | (value: number) => string | — | Custom formatter for the displayed value when not focused. |
disabled | boolean | false | Disables the input and both steppers. |
invalid | boolean | false | Marks the field as invalid (forwarded to the underlying Input). |
placeholder | string | — | Placeholder shown when the field is empty. |
className | string | — | Extra classes for the wrapper element. |
inputClassName | string | — | Extra classes for the underlying input. |
aria-label | string | — | Accessible name for the spinbutton when there is no visible label. |
aria-labelledby | string | — | ID of an element labelling the spinbutton. |
aria-describedby | string | — | ID of an element describing the spinbutton. |
id | string | — | Native id for the input. |
name | string | — | Native name for the input (form submission). |
onBlur | (event: FocusEvent<HTMLInputElement>) => void | — | Called when the input loses focus. |