DitherCharts

Stepper

Updated

Stepper shows where someone is in a multi-step form. Finished steps turn solid with a check, the current one gets an ink frame and aria-current, and the bar ahead stays dithered. With onStepChange, finished steps become buttons that go back. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { Stepper } from "@/components/dithercharts/stepper"

const [step, setStep] = useState(0)

<Stepper steps={["Account", "Plan", "Payment", "Review"]} current={step} onStepChange={setStep} label="Checkout" />
<Button onClick={() => setStep(step + 1)}>Next</Button>

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add stepper

Props

It renders a native element, so every other attribute that element takes passes through.

Stepper props
PropTypeDefaultDescription
stepsrequiredType readonly ReactNode[]Default –The steps' names, in order.
currentrequiredType numberDefault –The current step's index, from 0. Pass steps.length once every step is done.
onStepChangeType (index: number) => voidDefault –Makes each finished step a button that goes back to it, called with that step's index.
labelType stringDefault "Progress"The list's accessible name.
classNameType stringDefault –