Components

Stepper

A multi-step form and wizard component for React, built with Tailwind CSS and Motion: a progress line fills between steps, completed steps draw a check mark, and content panels slide in from the direction you're travelling while the container springs to the new height. Back, Next and Finish are wired up for you, with optional sync or async validation per step, horizontal or vertical layouts and a useStepper hook for custom controls.

  • Content panels
  • Per-step validation
  • Async validate
  • Direction-aware slides
  • Horizontal / vertical
  • useStepper hook
  • Focus management

Installation

$ npx shadcn@latest add https://duskui.com/r/stepper.json

Looking for a progress indicator only, without panels or navigation? Use the Stepper Progress block on the Progress page.

Usage

checkout.tsx
"use client"

import {
  Stepper,
  StepperControls,
  StepperNav,
  StepperPanel,
  StepperPanels,
} from "@/components/dusk/stepper/stepper"

const steps = [
  { title: "Cart" },
  { title: "Shipping", validate: () => isAddressValid() || "Add a shipping address." },
  { title: "Payment" },
]

export function Checkout() {
  return (
    <Stepper steps={steps} onComplete={placeOrder}>
      <StepperNav label="Checkout" />
      <StepperPanels>
        <StepperPanel index={0}>…</StepperPanel>
        <StepperPanel index={1}>…</StepperPanel>
        <StepperPanel index={2}>…</StepperPanel>
      </StepperPanels>
      <StepperControls completeLabel="Place order" />
    </Stepper>
  )
}

Examples

Vertical

orientation="vertical" puts the markers in a column beside the content (stacked on small screens) and slides panels vertically. Wrap the panels and controls in one element so they share the second column. StepperCompleted replaces the panels after the last step.

Repository

Pick a repository and the branch to deploy from. Pushes to it redeploy automatically.

Custom controls

Skip StepperNav and StepperControls and build your own with useStepper(). With linear={false} any step can be reached directly.

Command menu

Press ⌘K anywhere to jump to a page, run an action or search your docs.

API Reference

Props of Stepper; it also accepts any div attribute. StepperPanel takes an index, StepperNav a label, and StepperControls takes backLabel, nextLabel, completeLabel and restartLabel (null hides it). useStepper() returns the index, count, direction, completed, pending and error state plus next, back, goTo and reset.

PropTypeDefaultDescription
steps{ title; description?; validate? }[]—The steps. validate() may return false, an error message, or a Promise of either to block moving forward.
valuenumber—Controlled step index.
defaultValuenumber0Starting step when uncontrolled.
onValueChange(index: number) => void—Called when the step changes.
onComplete() => void—Called after the last step validates.
orientation"horizontal" | "vertical""horizontal"Markers above the content, or in a column beside it.
linearbooleantrueOnly steps already reached can be jumped to from the markers.

Accessibility

  • The markers are an ordered list inside a nav; the current one has aria-current="step" and each spells out “completed”, “current step” or “not started” for screen readers.
  • Steps you can't reach yet are aria-disabled buttons, so they stay discoverable without doing anything.
  • Each panel is a group labelled by its step; when the step changes, focus moves to the new panel so the next Tab lands on its first field.
  • Step changes, validation errors and completion are announced through a polite live region.
  • While async validation runs, Next is aria-busy and aria-disabled rather than disabled, so focus isn't lost.
  • With prefers-reduced-motion, panels cross-fade in place and the progress line and check mark appear without animating.