Stepper

Alpha

A multi-step progress indicator that shows the user's position in a sequential process. Supports horizontal and vertical orientations.

Import

import { Stepper } from "@compa11y/react";

Usage

Example.tsx
import { useState } from "react";
import { Stepper, Button } from "@compa11y/react";

function CheckoutStepper() {
  const [step, setStep] = useState(1);

  const steps = [
    { id: "cart", label: "Cart", status: "complete" as const },
    { id: "shipping", label: "Shipping", status: "active" as const },
    { id: "payment", label: "Payment", status: "pending" as const },
    { id: "confirm", label: "Confirmation", status: "pending" as const },
  ];

  return (
    <div>
      <Stepper steps={steps} currentStep={step} clickableSteps />
      <div style={{ display: "flex", gap: "8px", marginTop: "24px" }}>
        <Button variant="outline" onClick={() => setStep(s => s - 1)} disabled={step === 0}>
          Back
        </Button>
        <Button onClick={() => setStep(s => s + 1)} disabled={step === steps.length - 1}>
          Continue
        </Button>
      </div>
    </div>
  );
}

Features

  • aria-current='step' on the active step
  • Step status: pending, active, complete, error
  • Horizontal and vertical orientations
  • Optional clickable steps for non-linear flows
  • Screen reader announcements: 'Step N of M: label (status)'
  • Proper list semantics (ol > li)

Props

Stepper component props
PropTypeDefaultDescription
steps*StepItem[]-Ordered list of steps
currentStepnumber-Active step index (0-based)
onStepChange(step: number) => void-Called when a step is clicked
orientation'horizontal' | 'vertical''horizontal'Layout orientation
clickableStepsbooleanfalseAllow clicking completed steps

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Stepper
KeyAction
TabMoves between clickable steps
Enter / SpaceNavigates to a clickable step