NumberStepper
Loading example…
Counter with minus/plus buttons and a typeable value; ArrowUp/ArrowDown step it, Home/End jump.
Numeric by default; mode="string" hands the text to the caller (empty state, change event).
Import
Section titled “Import”import { NumberStepper } from "@jcsoftdev/ui/forms";Single-component entry points tree-shake to just this component: @jcsoftdev/ui/forms/number-stepper.
<NumberStepper defaultValue={2} min={0} max={10} step={1} aria-label="Cantidad de productos"/>| Prop | Type | Default | Description |
|---|---|---|---|
mode |
"string" | "number" |
||
value |
string | number |
||
defaultValue |
string | number |
||
onValueChange |
((value: number) => void) | ((value: string) => void) |
||
onChange |
ChangeEventHandler<HTMLInputElement> |
||
size |
"sm" | "md" |
sm (30px) matches a small Button or Input for dense rows; md (default) is the regular field height. |
|
incrementLabel |
string |
Accessible name of the plus button. Defaults to the localized verb followed by the field label. | |
decrementLabel |
string |
Accessible name of the minus button. Defaults to the localized verb followed by the field label. | |
min |
number |
||
max |
number |
||
step |
number |
||
disabled |
boolean |
||
unit |
string |
Text after the number, e.g. “min” or “unid.”; read by screen readers through aria-valuetext. | |
name |
string |
||
id |
string |
Id of the text input; Field sets it so the label points at the control. |
|
placeholder |
string |
||
required |
boolean |
||
invalid |
boolean |
||
aria-label |
string |
||
aria-labelledby |
string |
||
aria-describedby |
string |
||
aria-invalid |
boolean |
||
className |
string |
||
classNames |
Partial<Record<NumberStepperPart, string>> |
Per-part classes merged with cn; consumer classes win. className still targets the root and is merged last. |
|
intent |
string |
||
intentKey |
string |
* marks a required prop.
Storybook stories
Section titled “Storybook stories”- Default
- With Unit
- Decimals
- Disabled
- Controlled Value
- Narrow
- Brutal Preset
- In Shrink Wrap Row
- String Mode Caller Owned
- String Mode Uncontrolled Form
Source
Section titled “Source”packages/ui/src/forms/number-stepper/number-stepper.tsx