Stepper

Free

Fewer and more around a small number, such as parallel runs or seats, where the number rolls up or down the way it moved and each end disables its button.

npx shadcn@latest add @pixilui/stepper

Preview

The number rolls the way it moved, up or down, never just swapping.

When to use

Use it when

  • Small counts people nudge by one: parallel runs (1 to 8), seats, retries, replicas.
  • A value with a clear floor and ceiling that should never be typed out of range.

Use something else when

  • Large or precise numbers such as a spend limit: use an input.
  • A continuous range such as temperature: use a slider.

Installation

Terminal
npx shadcn@latest add @pixilui/stepper

Adds stepper.tsx with button.tsx, and installs clsx and tailwind-merge. First PixilUI item in this app? Add the registry once, as in Installation.

Usage

example.tsx
import { Stepper } from "@/components/pixilui/stepper";

<Stepper
  aria-label={aria-label}
  decrementIcon={decrementIcon}
  incrementIcon={incrementIcon}
  onValueChange={onValueChange}
/>

Fixed width from its two buttons and the number; fits anywhere a control does.

API reference

PropTypeDefault
aria-labelRequiredstring–What the number counts, for screen readers ("Parallel runs").
decrementIconRequiredReactNode–The fewer icon (Lucide Minus).
incrementIconRequiredReactNode–The more icon (Lucide Plus with data-stroke="heavy").
valuenumber–The value, controlled. Pair with onValueChange.
defaultValuenumber–The starting value when uncontrolled. Defaults to min.
onValueChange(value: number) => void | Promise<void>–Runs with the new value after a press of fewer or more.
minnumber0The lowest value; fewer is disabled there.

Also takes every native <div> attribute except defaultValue, onChange, and a ref.

Keyboard

TabMoves focus to fewer, then more.
EnterPresses the focused button: one step down or up.
SpaceThe same as Enter, on release.

Accessibility

  • A group named by aria-label (required), holding two native buttons named Fewer and More (decrementLabel, incrementLabel).
  • The number is a polite live region, so each change is read once.
  • At min or max the button is disabled; data-value carries the number for styling and tests.

Motion

  • The number rolls the way it moved: up for more, down for fewer, the old digit leaving as the new one arrives.
  • The leaving digit is dropped after its 150ms roll.
  • The buttons press like every button: scale .96 in 150ms.
  • Reduced motion: the number changes at once.

PixilUI Pro opens Thu 10 Dec. The first 20 licenses are $99.