NumberStepper
A spinbutton with − / + buttons, typing, clamping and a spoken unit.
Example
import { NumberStepper } from "@porcelana/ui";
export default function Example() {
return <NumberStepper label="Snooze" defaultValue={9} min={1} max={30} suffix="min" />;
}Import
import { NumberStepper } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
NumberStepper
Spinbutton with − / + buttons. Keyboard: ↑/↓ ±step, PageUp/PageDown ±10 steps, Home/End. Typing a number commits on blur or Enter.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | – | Accessible name. |
className | string | – | Class on the outer group. |
defaultValue | number | – | Initial value when uncontrolled. |
disabled | boolean | – | Prevents interaction and dims the control. |
id | string | – | Id of the input. Generated when omitted. |
max | number | 100 | Highest allowed value. |
min | number | 0 | Lowest allowed value. |
onValueChange | ((value: number) => void) | – | Called with the new value. |
step | number | 1 | Value change per arrow-key press. |
suffix | string | – | Visible unit after the number, e.g. "min". Also spoken via aria-valuetext. |
value | number | – | Controlled value. Use with onValueChange. |
Accessibility
- A real role="spinbutton" with aria-valuenow, min and max; suffix is spoken via aria-valuetext.
- Arrows ±step, Page Up/Down ±10 steps, Home/End; the buttons are skipped in tab order.
Mobile
- Opens the numeric keypad (inputMode="numeric").
- 44px buttons that disable at the limits.