Skip to content

Stepper

SM · 950B gzip budget

A wizard's progress, with each step's status in its accessible name.

Category
Navigation
Budget
sm, single-purpose control
External runtime
React / React DOM only
axe fixtureSSR rendersource scanbundle budget

Preview

Live fixture
Preview locale
  1. Cart (step 1 of 3, complete)
  2. Shipping (step 2 of 3, current)
  3. Payment (step 3 of 3, upcoming)

Try the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.

Install

npx shadcn@latest add https://gear5-ui.vercel.app/r/stepper.json

Copies the source into your project. Pulls in 1 shared registry item: cn.

New here? Set up Tailwind and import aliases first →

Source & props

Edit on GitHub ↗

Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.

import { cn } from "../lib/cn";

export interface Step {
  label: string;
}

export interface StepperProps {
  steps: Step[];
  /** 0-indexed. */
  current: number;
  className?: string;
}

/**
 * A wizard's progress, read by a screen reader as an ordered list with each
 * step's status in its accessible name — "Step 2 of 4, Shipping, current
 * step" — rather than only conveyed by which circle happens to be filled in.
 */
export function Stepper({ steps, current, className }: StepperProps) {
  return (
    <ol className={cn("flex items-center gap-2", className)}>
      {steps.map((step, index) => {
        const status = index < current ? "complete" : index === current ? "current" : "upcoming";

        return (
          <li key={step.label} className="flex flex-1 items-center gap-2">
            <div className="flex items-center gap-2">
              <span
                aria-hidden="true"
                className={cn(
                  "flex size-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",
                  status === "complete" && "bg-blue-600 text-on-accent",
                  status === "current" && "border-2 border-blue-600 text-blue-700 dark:text-blue-400",
                  status === "upcoming" && "border-2 border-neutral-300 text-neutral-400 dark:border-neutral-700",
                )}
              >
                {status === "complete" ? "✓" : index + 1}
              </span>
              <span
                className={cn(
                  "text-sm",
                  status === "upcoming" ? "text-neutral-400 dark:text-neutral-600" : "text-neutral-900 dark:text-neutral-100",
                )}
              >
                {step.label}
                <span className="sr-only">
                  {" "}
                  (step {index + 1} of {steps.length}, {status})
                </span>
              </span>
            </div>
            {index < steps.length - 1 && (
              <span aria-hidden="true" className={cn("h-px flex-1", status === "complete" ? "bg-blue-600" : "bg-neutral-200 dark:bg-neutral-800")} />
            )}
          </li>
        );
      })}
    </ol>
  );
}

What CI checks

Quality contract
  • Bundled, minified and gzipped against its tier budget
  • Audited by axe in the state previewed above
  • Rendered through react-dom/server with no browser globals
  • Scanned for network calls, dangerous sinks, and unguarded animation