Number Stepper
Seats, quantities, a price or a percentage. Type in the middle or step it; hold a button and it repeats faster; the value is clamped and snapped when you leave the field, and shown in the reader's own number format.
The decision inside it
Nothing is clamped mid-keystroke
Typing 120 into a field with a minimum of 10 does not turn the 1 into 10. The text is read when you leave the field or press Enter, then clamped, snapped to the step and formatted.
When to use it
Use Number Stepper for a small whole quantity people nudge up and down: seats, guests, copies. Give it min, max and step, and formatOptions for currency or percent. For a wide range, use Slider.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Number Stepper for this.
Install it: npx shadcn@latest add @layro/number-stepper
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/number-stepper.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { NumberStepper } from "@/components/ui/number-stepper";
export function SeatPicker({ seats, setSeats }: { seats: number; setSeats: (n: number) => void }) {
return <NumberStepper aria-label="Seats" value={seats} onValueChange={setSeats} min={1} max={50} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
value | number | The number. Controlled. |
defaultValue | number | The starting number when uncontrolled. Default min, or 0. |
onValueChange | (value: number) => void | Called with each new number, already clamped and snapped. |
min | number | Lowest allowed. |
max | number | Highest allowed. |
step | number | How much one press moves. Default 1. |
formatOptions | Intl.NumberFormatOptions | How the number is shown, e.g. { style: "currency", currency: "USD" }. |
allowInput | boolean | Allow typing in the middle. Default true. |
size | "sm" | "md" | sm 32px or md 36px tall. Default md. |
disabled | boolean | — |
name | string | The field's name inside a form. |
id | string | — |
className | string | — |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themefieldStates
All of them are drawn by the component. None is left for you to design.
- Default
- At minimum
- Currency
- Percent
- Buttons only
- Disabled
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.