ComponentsForm
Number Input
A number input with increment/decrement buttons and min/max/step support.
Default
With Step
With Min/Max Bounds
Disabled
Invalid
With Field
Quantity must be at least 1.
Installation
npx visor add number-inputThis copies two files into your project:
components/ui/number-input/number-input.tsx— the componentcomponents/ui/number-input/number-input.module.css— the styles
Usage
import { NumberInput } from '@/components/ui/number-input/number-input';
<NumberInput defaultValue={1} min={0} max={10} />API Reference
NumberInputProps
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Controlled numeric value. |
defaultValue | number | — | Default value for uncontrolled usage. |
onChange | (value: number | undefined) => void | — | Callback when the value changes. |
min | number | — | Minimum allowed value. |
max | number | — | Maximum allowed value. |
step | number | 1 | Increment/decrement step size. |
disabled | boolean | false | Disables the number input and buttons. |
Accessibility
- Always provide an
aria-labelor pair with a<Label>usinghtmlFor/id— the component has no visible label by default - Increment/decrement buttons have
aria-label="Increment"andaria-label="Decrement" - The input renders as
type="text"withinputmode="numeric"for appropriate mobile keyboard - Keyboard: Up/Down arrow keys increment/decrement the value; Tab navigates between the input and buttons
min/maxbounds are enforced both visually (buttons disable at bounds) and on input blur