# Stepper

> The steps of a wizard or a setup flow.

Component · Navigation · Halo kit · [Live page](https://ui.twentyfirst.media/halo/components/Stepper/)

The steps of a wizard or a setup flow. On wide screens the steps stand in a row with their number, label and an optional description; on phones (or always with `variant="compact"`) it says "Step 3 of 5" with the current step's name and a progress bar.

- `current` is the index of the current step: earlier steps are done, later ones upcoming. A step's own `state` wins (`"error"` for a step that needs attention).
- `onStepClick` turns done and error steps into buttons that go back to them.
- Screen readers hear the state after each step's name ("Account, done") and the current step is `aria-current="step"`.
- For a whole wizard page with the steps beside the content, see `Wizard`.

## Example

```tsx
import * as React from "react";
import { Button, Stepper } from "@twentyfirstmedia/halo";

const STEPS = [
  { label: "Account", description: "Name and email" },
  { label: "Workspace", description: "Name and address" },
  { label: "Invite", description: "Your team" },
  { label: "Billing", description: "Plan and card" },
  { label: "Done" },
];

export default function Preview() {
  const [step, setStep] = React.useState(2);
  return (
    <div className="tf-col" style={{ gap: 24 }}>
      <Stepper steps={STEPS} current={step} onStepClick={setStep} />
      <div className="tf-row" style={{ justifyContent: "flex-end" }}>
        <Button variant="ghost" disabled={step === 0} onClick={() => setStep(step - 1)}>
          Back
        </Button>
        <Button disabled={step === STEPS.length - 1} onClick={() => setStep(step + 1)}>
          Continue
        </Button>
      </div>
      <Stepper
        variant="compact"
        steps={[
          { label: "Domain" },
          { label: "DNS records", state: "error" },
          { label: "Mailboxes" },
        ]}
        current={1}
      />
    </div>
  );
}
```

## Props

### Stepper

| Prop | Type | Notes |
| --- | --- | --- |
| `steps` | `StepperStep[]` | Required |
| `current?` | `number` | Index of the current step: earlier steps are done, later ones upcoming. |
| `onStepClick?` | `(index: number) => void` | Makes done steps (and error steps) buttons that go back to them. |
| `label?` | `string` | Accessible name of the steps (default "Steps"). |
| `variant?` | `"auto" \| "compact"` | `auto` (default): the row of steps on wide screens, "Step 2 of 5" with a progress bar on phones. `compact` always shows the short form. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Button

| Prop | Type | Notes |
| --- | --- | --- |
| `variant?` | `"primary" \| "secondary" \| "soft" \| "ghost" \| "danger" \| "danger-solid"` |  |
| `size?` | `"md" \| "sm"` |  |
| `icon?` | `IconName` |  |
| `iconRight?` | `IconName` |  |
| `disabled?` | `boolean` |  |
| `type?` | `"button" \| "submit" \| "reset"` |  |
| `onClick?` | `(e: MouseEvent<HTMLButtonElement>) => void` |  |
| `children?` | `ReactNode` |  |
| `asChild?` | `boolean` | Render the single child element (a link, a router Link) with the button's look instead of a <button>. |
| `id?` | `string` |  |
| `name?` | `string` | Form field name and value, sent with the form when this button submits it. |
| `value?` | `string` |  |
| `form?` | `string` | The id of the form this button belongs to, when it sits outside it. |
| `title?` | `string` |  |
| `tabIndex?` | `number` |  |
| `autoFocus?` | `boolean` |  |
| `aria-label?` | `string` |  |
| `aria-labelledby?` | `string` |  |
| `aria-describedby?` | `string` |  |
| `aria-expanded?` | `boolean \| "true" \| "false"` | For disclosure and menu triggers: whether what the button controls is open. |
| `aria-controls?` | `string` |  |
| `aria-haspopup?` | `boolean \| "true" \| "false" \| "menu" \| "listbox" \| "tree" \| "grid" \| "dialog"` |  |
| `aria-pressed?` | `boolean \| "true" \| "false" \| "mixed"` | For toggle buttons. |
| `aria-current?` | `boolean \| "true" \| "false" \| "page" \| "step" \| "location" \| "date" \| "time"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
