# Stepper

- **[Atoms](/components/)**

Where someone is in a flow: numbered steps, the current one marked, each step's state said in words.

## When to use

- **Use for**: Showing progress through checkout, booking or onboarding.
- **Not for**: A percentage. Use Progress. Switching between views. Use Tabs.
- **Pairs with**: Button, Progress, a heading per step.

## Preview

stepper.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { Stepper } from '@/components/klarhimmel/ui/stepper';

export default function Example() {
  return (
    <Theme theme="brand">
      <Stepper
        aria-label="Booking progress"
        current={1}
        steps={[{ label: 'Dates' }, { label: 'Guests' }, { label: 'Payment' }]}
      />
    </Theme>
  );
}
```

## Import

- **CLI**

  ```
  npx shadcn add @klarhimmel/stepper
  ```
- **Import**

  ```
  import { Stepper } from '@/components/klarhimmel/ui/stepper';
  ```

- **Files**: stepper.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
- **Render in**: Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

## Examples

- **Descriptions**

  ```
  import { useState } from 'react';
  import { Button } from '@/components/klarhimmel/ui/button';
  import { Stepper } from '@/components/klarhimmel/ui/stepper';
  
  const steps = [
    { label: 'Choose a room', description: 'Seaside, garden or loft' },
    { label: 'Your details', description: 'Name and email' },
    { label: 'Pay', description: 'Card or invoice' },
  ];
  
  export default function StepperDescriptions() {
    const [current, setCurrent] = useState(2);
    return (
      <div className="flex w-[min(44rem,calc(100cqw-3rem))] flex-col gap-6">
        <Stepper aria-label="Checkout" steps={steps} current={current} onStepSelect={setCurrent} />
        <p role="status" className="text-kh-small text-kh-muted">You are on step {current + 1}: {steps[current]!.label}. Completed steps are buttons.</p>
        <div><Button variant="secondary" onClick={() => setCurrent(2)}>Jump to pay</Button></div>
      </div>
    );
  }
  ```
- **Narrow**

  ```
  import { Stepper } from '@/components/klarhimmel/ui/stepper';
  
  export default function StepperNarrow() {
    return (
      <div className="w-64 rounded-kh-lg border border-kh-line p-4">
        <Stepper
          aria-label="Onboarding"
          current={1}
          steps={[{ label: 'Create account' }, { label: 'Add your hotel', description: 'Name and address' }, { label: 'Invite the team' }]}
          labels={{ complete: 'Done', current: 'You are here', upcoming: 'Next' }}
        />
        <p className="mt-4 text-kh-caption text-kh-muted">In a narrow container the steps run down the side.</p>
      </div>
    );
  }
  ```

## Props

- **steps**: Required, in order.
- **current**: The step the person is on, counting from 0. Steps before it are complete; steps after it are upcoming.
- **aria-label**: Names the list. Required: "Booking progress".
- **labels**: What assistive tech hears beside each step, so state is never colour alone. Pass them translated.
- **onStepSelect**: With this, a completed step is a button that goes back to it.
- **className**: Extra classes, merged after the component's own.

## Accessibility

- Tab · Reaches completed steps when onStepSelect is given
- Enter / Space · Goes back to the focused completed step

[Accessibility](/get-started/accessibility)

An ordered list; the current step is aria-current="step" and every step says its state in words, so state is never colour alone.

[Previous](/components/doc-page)

[Next](/components/avatar-group)
