ui · Primitive
NumberInput
@devalok/shilp-sutra/ui/number-inputView in Storybook Hand-curated previews ship in rolling waves. See it live in Storybook →
Reference
Props
value: number (default: 0)
onValueChange: (value: number) => void
size: "xs" | "sm" | "md" | "lg"
state: "default" | "error" | "warning" | "success" (border color)
min: number
max: number
step: number (default: 1)
disabled: boolean
Defaults
value: 0
size: "md"
state: "default"
step: 1
min: Number.MIN_SAFE_INTEGER
max: Number.MAX_SAFE_INTEGER
Example
<NumberInput value={qty} onValueChange={setQty} min={1} max={99} />
Composability
- FormField auto-consumption: Inside
<FormField>, inheritsaria-describedby,aria-invalid,aria-required.statefrom FormField context drives the border color unless overridden. - IconProvider cascade: The
+and−stepper icons auto-size via IconProvider per the input size (xs/sm/md/lg → xs/sm/sm/md icons). - Controlled only (design choice): no
defaultValue— pairvalue+onValueChangeevery time. The min/max bounds disable the stepper buttons automatically when reached. - Label pairing: Manual via
<Label htmlFor="x" />+<NumberInput id="x" />.
Gotchas
- Controlled only — buttons won't work without onValueChange
Changes
v0.18.0
- Fixed Replaced
parseIntwithNumber(), handle empty input
v0.15.0
- Changed
mdsize font standardized totext-ds-md(14px)
v0.8.0
- Fixed FormField context consumption,
aria-labelfallback,parseIntradix parameter
v0.3.0
- Changed (BREAKING)
onChangerenamed toonValueChange - Changed Now extends HTMLAttributes — accepts all standard HTML props
v0.1.0
- Added Initial release