Skip to content

Quantity Stepper

InputMIT
View in Storybook

Increment / decrement quantity control with min/max clamping and keyboard support.

bun add @otfdashkit/ui

Preview

Quantity Stepper
Loading Storybook preview…

Code

import { useState } from 'react'
import { QuantityStepper } from '@otfdashkit/ui'

export function Example() {
  const [qty, setQty] = useState(1)
  return (
    <div className="flex flex-col items-center gap-3">
      <QuantityStepper value={qty} onValueChange={setQty} />
      <p className="font-mono text-xs text-muted-foreground">qty: {qty}</p>
    </div>
  )
}

Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the QuantityStepper source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
aria-labelstring'Quantity'
defaultValuenumber | (readonly string[] & number)1Uncontrolled initial quantity. Default 1.
disabledbooleanfalse
maxnumber99Maximum (increment disables here). Default 99.
minnumber1Minimum (decrement disables here). Default 1.
onValueChange(value: number) => voidFires with the clamped next quantity.
size'sm' | 'md''md'Control size. Default 'md'.
stepnumber1Increment/decrement step. Default 1.
valuenumberControlled quantity.