Skip to content
Porcelana

NumberStepper

A spinbutton with − / + buttons, typing, clamping and a spoken unit.

Inputs

Example

Example.tsx
import { NumberStepper } from "@porcelana/ui";

export default function Example() {
  return <NumberStepper label="Snooze" defaultValue={9} min={1} max={30} suffix="min" />;
}

Import

Import
import { NumberStepper } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app root

Props

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.

PropTypeDefaultDescription
labelrequiredstring–Accessible name.
classNamestring–Class on the outer group.
defaultValuenumber–Initial value when uncontrolled.
disabledboolean–Prevents interaction and dims the control.
idstring–Id of the input. Generated when omitted.
maxnumber100Highest allowed value.
minnumber0Lowest allowed value.
onValueChange((value: number) => void)–Called with the new value.
stepnumber1Value change per arrow-key press.
suffixstring–Visible unit after the number, e.g. "min". Also spoken via aria-valuetext.
valuenumber–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.