Skip to main content
Clever Ops

Stepper Button

A quantity stepper built with React and Tailwind, real spinbutton semantics, held auto-repeat with stated acceleration, direction-aware rolling digits, honest min/max clamping.

Preview & code

Loading Stepper Button preview

Installation

pnpm dlx shadcn@latest add @cleverui/button-stepper

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { ButtonStepper } from '@/components/ui/button-stepper'
Exampletsx
'use client'

import { useState } from 'react'
import { ButtonStepper } from '@/components/ui/button-stepper'

export default function ButtonStepperDemo() {
  const [seats, setSeats] = useState(4)
  const [copies, setCopies] = useState(1)

  return (
    <div className="mx-auto flex min-h-[360px] max-w-lg flex-col items-center justify-center gap-12 px-6 py-16">
      <div className="flex w-full flex-col items-center gap-4 text-center">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">
          Atlas Studio · seats
        </p>
        <p className="max-w-sm text-sm leading-relaxed text-muted-foreground">
          {seats} editor {seats === 1 ? 'seat' : 'seats'} · $28 per seat / month ·
          billing prorated today
        </p>
        <ButtonStepper
          value={seats}
          onValueChange={setSeats}
          min={1}
          max={50}
          label="Editor seats"
        />
      </div>

      <div className="flex w-full flex-col items-center gap-4 border-t border-border/60 pt-10 text-center">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">
          Print run · copies
        </p>
        <p className="max-w-sm text-sm leading-relaxed text-muted-foreground">
          Hold +/− to ramp quantity, bound bumps stop the repeat at 0 or 24.
        </p>
        <ButtonStepper
          value={copies}
          onValueChange={setCopies}
          min={0}
          max={24}
          size="sm"
          label="Print copies"
        />
      </div>
    </div>
  )
}

API reference

ButtonStepper accepts the following props.

PropTypeDefaultDescription
valuenumbercontrolled value; pair with onValueChange
defaultValuenumber1uncontrolled initial value, clamped into [min, max]
onValueChange(value: number) => voidfires on every committed step, already clamped
minnumber0
maxnumber99
stepnumber1
labelstring'Quantity'accessible name for the spinbutton readout
size'sm' | 'md''md'h-9 / h-11 instrument heights matching the button scale

…plus everything from Omit< React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'children' | 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onAnimationStart' >: className, event handlers, aria attributes and the rest pass straight through.

Frequently asked questions

How do I install the Stepper Button component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/button-stepper`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Stepper Button require?

Stepper Button uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Stepper Button to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services