# Stepper

Shows progress through a multi-step flow or checklist, with done, current, waiting and failed steps.

- Family: navigation
- Import: `import { Stepper } from "@senvenli/react/navigation";`
- Page: https://design.senvenli.com/docs/components/stepper
- JSON: https://design.senvenli.com/docs/components/stepper.json

## Example: A flow on one page

Done steps are pressable, so people can go back.

```tsx
import { Button } from "@senvenli/react/action";
import { Stack } from "@senvenli/react/layout";
import { Stepper } from "@senvenli/react/navigation";
import { useState } from "react";

const STEPS = [
  { id: "cart", label: "Cart" },
  { id: "delivery", label: "Delivery" },
  { id: "payment", label: "Payment" },
  { id: "review", label: "Review" },
];

export default function Example() {
  const [current, setCurrent] = useState("payment");
  const next = STEPS[STEPS.findIndex((step) => step.id === current) + 1];
  return (
    <Stack space="space-300" align="start">
      <div className="w-full">
        <Stepper aria-label="Checkout" steps={STEPS} currentStep={current} onStepPress={setCurrent} />
      </div>
      <Button variant="primary" isDisabled={!next} onPress={() => next && setCurrent(next.id)}>
        Continue
      </Button>
    </Stack>
  );
}
```

## Examples

### A vertical checklist

Each step has a line of detail: onboarding, setup.

```tsx
import { Stepper } from "@senvenli/react/navigation";

export default function Example() {
  return (
    <Stepper
      aria-label="Workspace setup"
      orientation="vertical"
      currentStep="team"
      steps={[
        { id: "account", label: "Create your account", description: "Name, email and password." },
        { id: "workspace", label: "Name the workspace", description: "Shown on invoices and emails." },
        { id: "team", label: "Invite your team", description: "Add at least one other member." },
        { id: "billing", label: "Add a payment method", description: "Charged when the trial ends." },
      ]}
    />
  );
}
```

### A journey with statuses

Steps that wait on someone or failed say so in words and an icon.

```tsx
import { Stepper } from "@senvenli/react/navigation";

export default function Example() {
  return (
    <Stepper
      aria-label="Payout setup"
      orientation="vertical"
      currentStep="documents"
      steps={[
        { id: "signup", label: "Sign up", isDone: true },
        { id: "documents", label: "Identity documents", description: "Upload a photo of your ID.", status: "needs-you" },
        { id: "bank", label: "Bank account", status: "with-provider", statusText: "With the bank · 1–2 business days" },
        { id: "tax", label: "Tax details", description: "The tax number did not match. Enter it again.", status: "failed" },
      ]}
    />
  );
}
```

### Finished

With isComplete every step shows done and none is current.

```tsx
import { Stepper } from "@senvenli/react/navigation";

export default function Example() {
  return (
    <Stepper
      aria-label="Order progress"
      isComplete
      currentStep="delivered"
      steps={[
        { id: "placed", label: "Placed" },
        { id: "packed", label: "Packed" },
        { id: "shipped", label: "Shipped" },
        { id: "delivered", label: "Delivered" },
      ]}
    />
  );
}
```

## Guidelines

### When to use it

- A flow of three or more steps: checkout, signup, setup.

### Use something else when

- [progress](https://design.senvenli.com/docs/components/progress.md): Only the share done matters, not named steps.
- [tabs](https://design.senvenli.com/docs/components/tabs.md): People move freely between views in any order.
- [timeline](https://design.senvenli.com/docs/components/timeline.md): The steps are past events.

## Accessibility

Built in:

- The current step has aria-current; the list is named with the overall progress.

You provide:

- Short step names.

## API reference

### Stepper

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| steps | `readonly StepperStep[]` |  | yes | Three to six steps, in order. |
| currentStep | `string` |  | yes | The step the reader is on: `aria-current="step"`. Ignored with `isComplete`. |
| isComplete | `boolean` |  | no | The flow is finished: every step shows its done state and none is current, so no step carries `aria-current`. The list is named with the overall state ("Progress, All steps done"), and the narrow one-line form reads "All steps done" over a full bar. A step's `status` or `statusText` still speaks for it, in the list and, under the done line, in the narrow form too ("Domain · With us"). A finished flow cannot also have a `failed` or `needs-you` step: that pairing contradicts itself and warns in development; settle the step first. Left out, nothing changes. |
| onStepPress | `(id: string) => void` |  | no | Makes done steps pressable (back to an earlier step). Leave it out where the flow cannot go back. |
| orientation | `"horizontal" \| "vertical"` |  | no | `horizontal` for a flow on one page (checkout, signup); `vertical` for checklists (onboarding, setup). |
| showStatus | `boolean` |  | no | Done and current steps say so in words too ("Done", "Now"), as on a journey across pages. On by default when any step has a `status`. |
| aria-label | `string` |  | no | Names the list; "Progress" by default. |

### Tokens it reads

`--ds-background-brand-bold`, `--ds-background-danger-bold`, `--ds-background-information-bold`, `--ds-background-neutral-pressed`, `--ds-background-warning-bold`, `--ds-border`, `--ds-border-bold`, `--ds-border-focused`, `--ds-border-selected`, `--ds-radius-full`, `--ds-radius-small`, `--ds-space-050`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-information`, `--ds-text-on-bold`, `--ds-text-on-brand`, `--ds-text-on-danger`, `--ds-text-on-warning`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-warning`

## Related

- [progress](https://design.senvenli.com/docs/components/progress.md)
