Skip to content

Stepper ​

A number between minus and plus buttons in one sunken group, for a value a person nudges, such as a font size.

tsx
import { Stepper } from '@adecore/ui';
tsx
import { Stepper } from '@adecore/ui';
import { useState } from 'react';

export default function StepperDemo() {
    const [size, setSize] = useState(14);
    const [lineHeight, setLineHeight] = useState(1.5);
    const [speed, setSpeed] = useState(1.25);

    return (
        <div className="flex items-center gap-4">
            <Stepper label="Font size" value={size} onValueChange={setSize} min={10} max={24} step={1} unit="px" />
            <Stepper label="Line height" value={lineHeight} onValueChange={setLineHeight} min={1} max={2.5} step={0.1} unit="×" />
            <Stepper label="Playback speed" value={speed} onValueChange={setSpeed} min={0.25} max={2} step={0.25} unit="×" />
        </div>
    );
}

The value stays within min and max. Steps round to two decimals, so a step below 0.01 does not work. A button disables at its end of the range. Button names include the label ("Font size: smaller"), and the number is a live region.

The number shows as many decimals as step (a step of 0.1 shows 1,0× in a Dutch region), unless you pass decimals. Its width stays fixed, so the buttons never move.

Props ​

PropTypeDefault
valuenumberRequired.
onValueChange(value: number) => voidRequired.
minnumberRequired.
maxnumberRequired.
stepnumberRequired.
labelstringRequired. The name of the group.
decimalsnumberthe places of step
unitstringPrinted after the number, muted, such as px or %.
classNamestring
refRef<HTMLDivElement>

StepperProps is an exported type.

Licenses and third-party notices are listed in each package.