Skip to content

Stepper

Stepper

A multi-step progress indicator. Steps are Stepper.Step children (Fragments, conditional steps and wrapper components are numbered in DOM order) rendered as an ordered list inside a role="group" root named "Progress" (override with aria-label). The active step's button carries aria-current="step"; completed and error steps announce their status ("Completed:", "Error:"; localized with statusLabels).

Server rendering: before hydration, steps are numbered by their position among the Stepper's children (Fragments flattened), so a wrapper component that renders more or fewer than one step is numbered correctly only after hydration. Pin such steps with index if the server HTML must already be exact.

Compound access (Stepper.Step) needs a client module; React Server Components import the flat name StepperStep instead.

Examples

Default

  1. Completed: 1. AccountCreate your account
  2. 2. ProfileSet up your profile
  3. 3. ReviewReview and submit
export const Default: Story = {
  render: (args) => (
    <Stepper {...args}>
      <Stepper.Step label="Account" description="Create your account" />
      <Stepper.Step label="Profile" description="Set up your profile" />
      <Stepper.Step label="Review" description="Review and submit" />
    </Stepper>
  ),
};

Vertical

  1. Completed: 1. Select planChoose a subscription plan
  2. 2. PaymentEnter payment details
  3. 3. ConfirmationReview your order
  4. 4. CompleteOrder placed
export const Vertical: Story = {
  args: {
    orientation: 'vertical',
  },
  render: (args) => (
    <Stepper {...args}>
      <Stepper.Step label="Select plan" description="Choose a subscription plan" />
      <Stepper.Step label="Payment" description="Enter payment details" />
      <Stepper.Step label="Confirmation" description="Review your order" />
      <Stepper.Step label="Complete" description="Order placed" />
    </Stepper>
  ),
};

With Error And Disabled

  1. Completed: 1. Details
  2. Error: 2. Verification
  3. 3. Extras
  4. 4. Complete
export const WithErrorAndDisabled: Story = {
  render: (args) => (
    <Stepper {...args}>
      <Stepper.Step label="Details" />
      <Stepper.Step label="Verification" error />
      <Stepper.Step label="Extras" disabled />
      <Stepper.Step label="Complete" />
    </Stepper>
  ),
};

Localized

  1. Fullført: 1. Konto
  2. Feil: 2. Betaling
  3. 3. Bekreft
export const Localized: Story = {
  args: {
    'aria-label': 'Fremdrift',
    lang: 'nb',
    defaultActiveStep: 2,
    statusLabels: { completed: 'Fullført:', error: 'Feil:' },
  },
  render: (args) => (
    <Stepper {...args}>
      <Stepper.Step label="Konto" />
      <Stepper.Step label="Betaling" error />
      <Stepper.Step label="Bekreft" />
    </Stepper>
  ),
};

With Icons

  1. Completed: 1. Cart
  2. 2. Shipping
  3. 3. Payment
export const WithIcons: Story = {
  render: (args) => (
    <Stepper {...args}>
      <Stepper.Step
        label="Cart"
        icon={
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
            <path
              d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4z"
              stroke="currentColor"
              strokeWidth="2"
            />
            <path d="M3 6h18" stroke="currentColor" strokeWidth="2" />
            <path d="M16 10a4 4 0 01-8 0" stroke="currentColor" strokeWidth="2" />
          </svg>
        }
      />
      <Stepper.Step
        label="Shipping"
        icon={
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
            <rect x="1" y="3" width="15" height="13" rx="2" stroke="currentColor" strokeWidth="2" />
            <path d="M16 8h4l3 3v5h-7V8z" stroke="currentColor" strokeWidth="2" />
            <circle cx="5.5" cy="18.5" r="2.5" stroke="currentColor" strokeWidth="2" />
            <circle cx="18.5" cy="18.5" r="2.5" stroke="currentColor" strokeWidth="2" />
          </svg>
        }
      />
      <Stepper.Step
        label="Payment"
        icon={
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
            <rect x="1" y="4" width="22" height="16" rx="2" stroke="currentColor" strokeWidth="2" />
            <path d="M1 10h22" stroke="currentColor" strokeWidth="2" />
          </svg>
        }
      />
    </Stepper>
  ),
};

Linear

  1. 1. Personal Info
  2. 2. Address
  3. 3. Payment
  4. 4. Confirm
export const Linear: Story = {
  args: {
    linear: true,
  },
  render: ({ onStepChange, ...args }) => {
    const lastStep = 3;
    const [step, setStep] = React.useState(0);
    const changeStep = (next: number) => {
      setStep(next);
      onStepChange?.(next);
    };
    const atStart = step === 0;
    const atEnd = step === lastStep;
    return (
      <div className="flex flex-col gap-6">
        <Stepper activeStep={step} onStepChange={changeStep} {...args}>
          <Stepper.Step label="Personal Info" />
          <Stepper.Step label="Address" />
          <Stepper.Step label="Payment" />
          <Stepper.Step label="Confirm" />
        </Stepper>
        <div className="flex gap-2">
          <Button
            aria-disabled={atStart || undefined}
            onClick={() => {
              if (!atStart) changeStep(step - 1);
            }}
          >
            Back
          </Button>
          <Button
            appearance="primary"
            aria-disabled={atEnd || undefined}
            onClick={() => {
              if (!atEnd) changeStep(step + 1);
            }}
          >
            Next
          </Button>
        </div>
      </div>
    );
  },
};

Props

NameTypeRequiredDefaultDescription
activeStepnumberNo

Controlled index (0-based) of the currently active step.

defaultActiveStepnumberNo0

Default active step index for uncontrolled usage.

onStepChange(step: number) => voidNo

Called with the step index whenever a step is activated (click, Enter or Space) — also when the active step is activated again (0.4 semantics). Not called for disabled or unreachable steps.

orientation'horizontal' | 'vertical'No'horizontal'

Layout orientation of the stepper.

linearbooleanNofalse

Whether navigation is restricted to sequential steps: only steps up to the one after the active step can be activated; later steps are aria-disabled and leave the tab order.

statusLabels{ completed?: string; error?: string }No{ completed: 'Completed:', error: 'Error:' }

Visually hidden status text read before the number of a completed or error step ("Completed:
2. Profile"), for localization: { completed: 'Fullført:', error: 'Feil:' }. A label that is not given keeps its English default; '' leaves that status out of the step names.

refReact.Ref<HTMLDivElement>No

Ref to the root <div> element.

slotProps{ list?: SlotPart<'ol'> }No

Props for the list the stepper draws inside its root, merged into its own: your classes after its classes (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref attached beside the stepper's own. Every attribute the stepper sets on it is locked. A part takes no children (the steps are yours, and each takes slotProps of its own). Fluent UI has no Stepper.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • list
  • Stepper.Step

Stable class names

PartClass
rootwave-stepper
listwave-stepper__list