Adaptive Stepper

A number stepper that rolls its value and reshapes at the limits.

Preview

"use client";

import {
  AdaptiveStepper,
  AdaptiveStepperDecrement,
  AdaptiveStepperIncrement,
  AdaptiveStepperValue,
} from "@/components/motion/adaptive-stepper";

export function AdaptiveStepperPreview() {
  return (
    <div className="flex min-h-[320px] w-full items-center justify-center px-4">
      <AdaptiveStepper defaultValue={2} min={0} max={3} aria-label="Guests">
        <AdaptiveStepperDecrement />
        <AdaptiveStepperValue />
        <AdaptiveStepperIncrement />
      </AdaptiveStepper>
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/adaptive-stepper

API Reference

AdaptiveStepper

value?
number

The current value, for controlled use.

defaultValue?
number

The initial value when uncontrolled. Default: 0

Default0
onValueChange?
((value: number) => void)

Called with the new value when a button steps it.

min?
number

Lowest allowed value. Default: 0

Default0
max?
number

Highest allowed value. Default: 10

Default10
step?
number

Amount each press adds or removes. Default: 1

Default1
disabled?
boolean

Disables both buttons. Default: false

Defaultfalse
name?
string

Form field name. Renders a hidden input carrying the value.

formatValueText?
((value: number) => string)

Formats the value read to screen readers. Defaults to a locale number.

className?
string

Classes merged onto the root fieldset.

aria-label?
string

Accessible name for the stepper. Default: "Quantity"

labels?
Partial<{ label: string; summary: string; decrease: string; increase: string; }>

Override any built-in string. `{label}` and `{value}` fill `summary`.

AdaptiveStepperDecrement

onClick?
((event: MouseEvent<HTMLButtonElement, MouseEvent>) => void)

Called on click before the step. Call `preventDefault()` to skip the step.

ref?
Ref<HTMLButtonElement>

Ref to the underlying button element.

className?
string

Classes merged onto the root element.

AdaptiveStepperValue

className?
string

Classes merged onto the root element.

AdaptiveStepperIncrement

onClick?
((event: MouseEvent<HTMLButtonElement, MouseEvent>) => void)

Called on click before the step. Call `preventDefault()` to skip the step.

ref?
Ref<HTMLButtonElement>

Ref to the underlying button element.

className?
string

Classes merged onto the root element.

Updated