# Stepper

> Progress through a multi-step flow such as onboarding or checkout, horizontal or vertical.

Status: beta. Category: Navigation.

```ts
import { Stepper } from '@glyphui/ui'
```

Exports: `Stepper`, `stepperStyles`.

## Notes

- Renders an ordered list; the current step has aria-current="step" and every step announces its status.
- Statuses come from current: earlier steps are complete, later ones upcoming. Set status on a step to override.

## Stepper props

| Prop | Type | Default | Description |
|---|---|---|---|
| `current` (required) | `number` |  | Index of the current step. Earlier steps are complete, later ones upcoming. |
| `steps` (required) | `readonly StepperStep[]` |  |  |
| `onStepClick` | `((index: number) => void)` |  | Makes completed steps clickable, e.g. to go back in a wizard. |
| `orientation` | `"horizontal" \| "vertical"` |  |  |

## Example: Wizard

Completed steps are clickable when onStepClick is set.

```tsx
import { Button, Stepper, Text } from '@glyphui/ui'
import { useState } from 'react'

const steps = [
  { title: 'Account' },
  { title: 'Workspace' },
  { title: 'Invite team' },
  { title: 'Done' },
]

export default function Example() {
  const [current, setCurrent] = useState(1)
  return (
    <div className="grid w-full max-w-xl gap-6">
      <Stepper steps={steps} current={current} onStepClick={setCurrent} aria-label="Onboarding" />
      <div className="flex items-center justify-between gap-3">
        <Text size="small" tone="muted">
          Step {current + 1} of {steps.length}
        </Text>
        <div className="flex gap-2">
          <Button
            variant="outline"
            size="sm"
            disabled={current === 0}
            onClick={() => setCurrent((c) => c - 1)}
          >
            Back
          </Button>
          <Button
            size="sm"
            disabled={current === steps.length - 1}
            onClick={() => setCurrent((c) => c + 1)}
          >
            Continue
          </Button>
        </div>
      </div>
    </div>
  )
}
```

## Example: Vertical with descriptions

```tsx
import { Stepper } from '@glyphui/ui'

export default function Example() {
  return (
    <Stepper
      orientation="vertical"
      current={2}
      aria-label="Order status"
      className="max-w-sm"
      steps={[
        { title: 'Order placed', description: 'Oct 14, 09:12' },
        { title: 'Payment confirmed', description: 'Oct 14, 09:13' },
        { title: 'Packed', description: 'Ships from Frankfurt' },
        { title: 'Shipped' },
        { title: 'Delivered' },
      ]}
    />
  )
}
```

## Example: Error state

Override a step’s status to flag a problem.

```tsx
import { Stepper } from '@glyphui/ui'

export default function Example() {
  return (
    <Stepper
      className="max-w-xl"
      current={2}
      aria-label="Checkout"
      steps={[
        { title: 'Cart' },
        { title: 'Shipping' },
        { title: 'Payment', description: 'Card declined', status: 'error' },
        { title: 'Review' },
      ]}
    />
  )
}
```

Live page: https://glyphui.xyz/components/stepper
