# Stepper

Stepper component: a multi-step wizard indicator with list, item, trigger, indicator, title, separator and content parts. Choose numbered steps or progress bars and one of four rail colors; navigation is linear by default.

Component · Stepper · https://01orbital.dev/docs/components/stepper

## Installation

```bash
npx shadcn@latest add @01orbital/stepper
```

## Usage

```tsx
"use client"

import { useEffect, useRef, useState } from "react"
import { CheckIcon } from "@phosphor-icons/react"

import {
  Stepper,
  StepperContent,
  StepperIndicator,
  StepperItem,
  StepperList,
  StepperSeparator,
  StepperTitle,
  StepperTrigger,
} from "@/components/stepper/stepper"
import { Button } from "@/components/ui/button"

// Every word on the page. Change copy here, not in the markup.
const COPY = {
  back: "Back",
  next: "Continue",
  steps: [
    { title: "Choose", body: "Choose your pieces." },
    { title: "Arrange", body: "Arrange them together." },
    { title: "Review", body: "Review your composition." },
  ],
} as const

export default function StepperDemo() {
  const [step, setStep] = useState(0)
  const panel = useRef<HTMLDivElement>(null)
  const shown = useRef(step)

  // Next and Back can disable under the pointer, so focus moves to the new step.
  useEffect(() => {
    if (shown.current !== step) panel.current?.focus()
    shown.current = step
  }, [step])

  return (
    <div className="flex min-h-full w-full flex-1 items-center justify-center p-6 sm:p-10">
      <Stepper value={step} onValueChange={setStep} className="max-w-xl">
        <StepperList>
          {COPY.steps.map((s, i) => (
            <StepperItem key={s.title} value={i}>
              <StepperTrigger>
                <StepperIndicator>
                  <CheckIcon
                    weight="bold"
                    aria-hidden="true"
                    className="hidden size-4 group-data-[state=completed]/step:block"
                  />
                  <span className="group-data-[state=completed]/step:hidden">
                    {i + 1}
                  </span>
                </StepperIndicator>
                {/* Kept for screen readers on a phone: it names the step. */}
                <StepperTitle className="sr-only sm:not-sr-only">
                  {s.title}
                </StepperTitle>
              </StepperTrigger>
              <StepperSeparator className="group-last/step:hidden" />
            </StepperItem>
          ))}
        </StepperList>

        {COPY.steps.map((s, i) => (
          <StepperContent
            key={s.title}
            value={i}
            ref={panel}
            tabIndex={-1}
            className="outline-none"
          >
            <p>{s.body}</p>
          </StepperContent>
        ))}

        <div className="flex gap-3">
          <Button
            variant="outline"
            disabled={step === 0}
            onClick={() => setStep(step - 1)}
          >
            {COPY.back}
          </Button>
          <Button
            disabled={step === COPY.steps.length - 1}
            onClick={() => setStep(step + 1)}
          >
            {COPY.next}
          </Button>
        </div>
      </Stepper>
    </div>
  )
}
```

This example installs with everything it uses:

```bash
npx shadcn@latest add @01orbital/stepper-demo
```

## API reference

### Stepper

A set of steps, each with an optional panel, for a multi-step form or a progress count. Holds a `StepperList` of `StepperItem` steps and any `StepperContent` panels. Set the selected step with `value` and `onValueChange`, or let it manage its own from `defaultValue`.

It shows position, not progress: a step before the selected one reads as completed and a step after it as inactive, whichever way the user moved. When a form tracks real completion, pass `completed` to each `StepperItem` instead. Next and Back buttons change the step with `setValue` from `useStepper`. Each `StepperContent` mounts only while its step is selected, unless it has `keepMounted`.

The indicators are 28px; set `--stepper-indicator-size` on the `Stepper` to change them, and the rail stays aligned to their centers.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultValue?` | `number \| (readonly string[] & number)` | `0` | The first selected step when `value` is not set. Defaults to 0. |
| `value?` | `number` |  | The selected step, when you control it with `onValueChange`. |
| `onValueChange?` | `((value: number) => void)` |  | Called with the new step when a trigger or `setValue` changes it. |
| `linear?` | `boolean` | `true` | While true (the default), steps after the selected one are disabled, so triggers reach only the selected step and earlier ones. Set false to let any step be selected. |
| `rail?` | `StepperRail` | `"soft"` | The color of the filled rail. `soft` (the default) is the text color at 40%, `ink` the full text color, `muted` the muted text color. In `bars`, `soft` fills with the full text color. `accent` paints the rail, the completed indicators and the selected step's ring with `--stepper-accent`; set it on the `Stepper` or above it, with `--stepper-accent-foreground` (white by default) for text on the accent. |
| `variant?` | `StepperVariant` | `"steps"` | `steps` (the default) joins the indicators with a 1px rail. `bars` turns each `StepperSeparator` into a 4px rounded segment, filled through the selected step; give each item only a separator and a visually hidden `StepperTitle`. |
| `current?` | `boolean` | `true` | While true (the default), the selected step carries `aria-current="step"`: on its trigger, or on the item when it has none, as in `bars` or a read-only list. Set false for a read-only count, such as 3 of 5 done, that has no current step to announce. |

### StepperList

The ordered list that holds the `StepperItem` steps, in one row.

`layout` says where each step's title sits: `inline` (the default) beside its indicator, `stacked` under it. In `stacked` the list aligns the rail to the indicators' centers, so nothing needs nudging by hand.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `layout?` | `"inline" \| "stacked"` | `"inline"` | `inline` puts each title beside its indicator, `stacked` under it. |

### StepperItem

One step, inside `StepperList`. It works out its state from its `value` (`completed`, `active` or `inactive`) and sets it as `data-state` for its parts and your styles. Put a `StepperTrigger` and a `StepperSeparator` inside it, or only a separator and a title in the `bars` variant.

Items share the row's width, except the last in `steps`, which is only as wide as its content.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number \| (readonly string[] & number)` |  | This step's number, compared with the `Stepper` value to set its state. |
| `disabled?` | `boolean` |  | Disables this step's trigger. Linear mode disables later steps anyway. |
| `completed?` | `boolean` |  | Whether this step is done, when a form tracks that itself. Unset, a step before the selected one counts as completed. The selected step is always `active`. |

### StepperTrigger

The button that selects its step, built on the stock `Button` with no padding or fill. Put a `StepperIndicator` and a `StepperTitle` inside it. A click selects the step unless the step is disabled or your `onClick` calls `event.preventDefault()`.

The selected step's trigger carries `aria-current="step"`, and a disabled trigger keeps its full opacity. `className` takes a string only.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className?` | `string` |  | Extra classes, as a string only: the stock `Button` does not accept a `className` function. |
| `size?` | `"default" \| "xs" \| "sm" \| "lg" \| "icon" \| "icon-xs" \| "icon-sm" \| "icon-lg" \| null` |  | The stock `Button` size, usually left unset. The trigger replaces the text sizes' height, padding and gap with its own, so only `xs` changes it, with smaller text and icons. |
| `variant?` | `"link" \| "default" \| "secondary" \| "destructive" \| "outline" \| "ghost" \| null` |  | The stock `Button` variant, `ghost` by default here. The trigger cancels the hover fill whatever the variant, so another variant changes only the resting fill, border and text color. |

### StepperContent

The panel for one step, shown while that step is selected. Place it inside `Stepper`, usually after `StepperList`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number` |  | The step this panel belongs to. |
| `keepMounted?` | `boolean` | `false` | Keeps the panel mounted but hidden while another step is selected, so its inputs keep their values. Defaults to false. |

## Dependencies

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

- [Button](https://01orbital.dev/docs/components/button)

The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.

npm: `cn`

## Examples

- **Stepper Visit Guide** (`@01orbital/stepper-visit-guide`): Stepper example: a numbered stepper with Back and Next controls that walks through a clinic visit preparation guide. Shows a multi-step wizard with navigation buttons.
- **Stepper Edition Proofs** (`@01orbital/stepper-edition-proofs`): Stepper Edition Proofs: an example of stepper.
- **Stepper Workspace Onboarding** (`@01orbital/stepper-workspace-onboarding`): Stepper example: an onboarding flow with numbered stops and working Back and Next controls. Shows a setup wizard for workspace or account onboarding.
- **Stepper Setup Bars** (`@01orbital/stepper-setup-bars`): Stepper example: a setup summary using chunky progress bar segments and a read-only completion count. Shows the bar stepper as a non-interactive onboarding progress indicator.
- **Stepper Workshop Agenda** (`@01orbital/stepper-workshop-agenda`): Stepper example: a workshop agenda with a vertical rail, numbered stops and selectable session notes. Shows the vertical stepper as an agenda or itinerary.

## Used in blocks

- [Application Status](https://01orbital.dev/docs/blocks/application-status)
- [Checkout](https://01orbital.dev/docs/blocks/checkout)
- [Checkout Bars](https://01orbital.dev/docs/blocks/checkout-bars)
- [Compact Steps](https://01orbital.dev/docs/blocks/compact-steps)
- [Domain Setup](https://01orbital.dev/docs/blocks/domain-setup)
- [Domain Setup Bars](https://01orbital.dev/docs/blocks/domain-setup-bars)
- [Import Wizard](https://01orbital.dev/docs/blocks/import-wizard)
- [Import Wizard Bars](https://01orbital.dev/docs/blocks/import-wizard-bars)
- [Install Guide](https://01orbital.dev/docs/blocks/install-guide)
- [Orb Steps](https://01orbital.dev/docs/blocks/orb-steps)
- [Plan Change Flow](https://01orbital.dev/docs/blocks/plan-change-01)
- [Repo Deploy](https://01orbital.dev/docs/blocks/repo-deploy)
- [Repo Deploy Bars](https://01orbital.dev/docs/blocks/repo-deploy-bars)
- [Setup Progress](https://01orbital.dev/docs/blocks/setup-progress)
- [Signup Wizard](https://01orbital.dev/docs/blocks/signup-wizard)
- [Signup Wizard Bars](https://01orbital.dev/docs/blocks/signup-wizard-bars)
- [Upload Stages](https://01orbital.dev/docs/blocks/upload-stages)
- [Workspace Setup](https://01orbital.dev/docs/blocks/workspace-setup)
