# Stepper

A progress indicator for sequential flows such as onboarding, checkout, and multi-step dialogs.

Stepper shows where someone is in a sequence. Each step derives its state from one active value, and the connector fills as that value advances.

```tsx
import { Button, Stack, Stepper } from "@zentara-co/zenos-ui";
import { useState } from "react";

const checkoutSteps = [
  { step: 1, title: "Your details" },
  { step: 2, title: "Company" },
  { step: 3, title: "Confirm" },
] as const;

function StepperPreviewExample() {
  const [step, setStep] = useState(1);

  return (
    <Stack gap="6" className="w-full max-w-xl">
      <Stepper aria-label="Checkout" value={step} onValueChange={setStep}>
        {checkoutSteps.map((item, index) => (
          <Stepper.Item key={item.step} step={item.step}>
            <Stepper.Trigger>
              <Stepper.Indicator />
              <Stepper.Title>{item.title}</Stepper.Title>
            </Stepper.Trigger>
            {index < checkoutSteps.length - 1 ? <Stepper.Separator /> : null}
          </Stepper.Item>
        ))}
      </Stepper>
      <Stack direction="row" gap="2" justify="end">
        <Button
          variant="primary"
          disabled={step === 1}
          onClick={() => setStep((current) => current - 1)}
        >
          Back
        </Button>
        <Button
          disabled={step === checkoutSteps.length}
          onClick={() => setStep((current) => current + 1)}
        >
          Next
        </Button>
      </Stack>
    </Stack>
  );
}
```

## Import

```tsx
import { Stepper } from "@zentara-co/zenos-ui";
```

## Anatomy

`Stepper.Trigger` is optional. Include it when a step can be selected, and omit it for a read-only progress indicator. Omit `Stepper.Separator` on the last step. `Stepper.Description` sits with the title when a step needs supporting copy.

```tsx
<Stepper value={step} onValueChange={setStep}>
  <Stepper.Item step={1}>
    <Stepper.Trigger>
      <Stepper.Indicator />
      <Stepper.Title>Account</Stepper.Title>
    </Stepper.Trigger>
    <Stepper.Separator />
  </Stepper.Item>
</Stepper>
```

## Value

Pass `value` and `onValueChange` when Back and Next buttons, or another control, own the flow. Use `defaultValue` when the stepper only reports progress. Steps are 1-based.

A step earlier than `value` is completed, the matching step is active, and a later step is inactive. The separator on a completed step fills toward the next one.

## Orientation

`orientation="horizontal"` lays steps in a row with a flexible connector. `orientation="vertical"` stacks them, with the connector running down the indicator column. Vertical orientation leaves room for a description under each title.

```tsx
import { Grid, Stack, Stepper, Text } from "@zentara-co/zenos-ui";

function StepperOrientationExample() {
  const steps = [
    { step: 1, title: "Cart" },
    { step: 2, title: "Shipping" },
    { step: 3, title: "Payment" },
  ] as const;

  return (
    <Grid columns={{ base: 1, md: 2 }} gap="8" className="w-full">
      {(["horizontal", "vertical"] as const).map((orientation) => (
        <Stack key={orientation} gap="3">
          <Text size="s" weight="medium" color="subtle" className="capitalize">
            {orientation}
          </Text>
          <Stepper
            aria-label={`${orientation} checkout`}
            defaultValue={2}
            orientation={orientation}
          >
            {steps.map((item, index) => (
              <Stepper.Item key={item.step} step={item.step}>
                <Stepper.Trigger>
                  <Stepper.Indicator />
                  <Stepper.Title>{item.title}</Stepper.Title>
                </Stepper.Trigger>
                {index < steps.length - 1 ? <Stepper.Separator /> : null}
              </Stepper.Item>
            ))}
          </Stepper>
        </Stack>
      ))}
    </Grid>
  );
}
```

## Descriptions

Pair `Stepper.Title` and `Stepper.Description` in a vertical stack beside the indicator.

```tsx
import { Stepper } from "@zentara-co/zenos-ui";

function StepperDescriptionExample() {
  const steps = [
    { description: "Your login details", step: 1, title: "Account" },
    { description: "Name, photo, and bio", step: 2, title: "Profile" },
    { description: "Confirm and finish", step: 3, title: "Review" },
  ] as const;

  return (
    <Stepper
      aria-label="Account setup"
      className="max-w-sm"
      defaultValue={1}
      orientation="vertical"
    >
      {steps.map((item, index) => (
        <Stepper.Item key={item.step} step={item.step}>
          <Stepper.Trigger>
            <Stepper.Indicator />
            <span className="flex min-w-0 flex-col gap-0.5">
              <Stepper.Title>{item.title}</Stepper.Title>
              <Stepper.Description>{item.description}</Stepper.Description>
            </span>
          </Stepper.Trigger>
          {index < steps.length - 1 ? <Stepper.Separator /> : null}
        </Stepper.Item>
      ))}
    </Stepper>
  );
}
```

## Density

`density="comfortable"` is the default for onboarding and page flows. `density="compact"` shrinks the indicator and type for dialogs and dense application UI. Density also inherits from `DensityProvider`.

```tsx
import { Grid, Stack, Stepper, Text } from "@zentara-co/zenos-ui";

function StepperDensityExample() {
  const steps = [
    { step: 1, title: "Plan" },
    { step: 2, title: "Billing" },
    { step: 3, title: "Done" },
  ] as const;

  return (
    <Grid columns={{ base: 1, md: 2 }} gap="8" className="w-full">
      {(["comfortable", "compact"] as const).map((density) => (
        <Stack key={density} gap="3">
          <Text size="s" weight="medium" color="subtle" className="capitalize">
            {density}
          </Text>
          <Stepper aria-label={`${density} plan`} defaultValue={2} density={density}>
            {steps.map((item, index) => (
              <Stepper.Item key={item.step} step={item.step}>
                <Stepper.Trigger>
                  <Stepper.Indicator />
                  <Stepper.Title>{item.title}</Stepper.Title>
                </Stepper.Trigger>
                {index < steps.length - 1 ? <Stepper.Separator /> : null}
              </Stepper.Item>
            ))}
          </Stepper>
        </Stack>
      ))}
    </Grid>
  );
}
```

## Loading and disabled

Set `loading` on the active `Stepper.Item` to replace its number with a spinner while that step validates or submits. Set `disabled` on a step the person cannot select yet. A disabled step stays out of the sequence until the flow enables it.

```tsx
import { Stepper } from "@zentara-co/zenos-ui";

function StepperStateExample() {
  return (
    <Stepper aria-label="Verification" className="max-w-xl" value={2}>
      <Stepper.Item step={1}>
        <Stepper.Trigger>
          <Stepper.Indicator />
          <Stepper.Title>Details</Stepper.Title>
        </Stepper.Trigger>
        <Stepper.Separator />
      </Stepper.Item>
      <Stepper.Item loading step={2}>
        <Stepper.Trigger>
          <Stepper.Indicator />
          <Stepper.Title>Verifying</Stepper.Title>
        </Stepper.Trigger>
        <Stepper.Separator />
      </Stepper.Item>
      <Stepper.Item disabled step={3}>
        <Stepper.Trigger>
          <Stepper.Indicator />
          <Stepper.Title>Finish</Stepper.Title>
        </Stepper.Trigger>
      </Stepper.Item>
    </Stepper>
  );
}
```

## Variants

`variant="outline"` is the default: upcoming steps stay quiet, the active step uses the selected surface, and a completed step fills with the primary brand color. `variant="solid"` fills every indicator with that same primary color.

```tsx
import { Grid, Stack, Stepper, Text } from "@zentara-co/zenos-ui";

function StepperVariantExample() {
  const steps = [
    { step: 1, title: "Plan" },
    { step: 2, title: "Billing" },
    { step: 3, title: "Done" },
  ] as const;

  return (
    <Grid columns={{ base: 1, md: 2 }} gap="8" className="w-full">
      {(["outline", "solid"] as const).map((variant) => (
        <Stack key={variant} gap="3">
          <Text size="s" weight="medium" color="subtle" className="capitalize">
            {variant}
          </Text>
          <Stepper aria-label={`${variant} plan`} defaultValue={2} variant={variant}>
            {steps.map((item, index) => (
              <Stepper.Item key={item.step} step={item.step}>
                <Stepper.Trigger>
                  <Stepper.Indicator />
                  <Stepper.Title>{item.title}</Stepper.Title>
                </Stepper.Trigger>
                {index < steps.length - 1 ? <Stepper.Separator /> : null}
              </Stepper.Item>
            ))}
          </Stepper>
        </Stack>
      ))}
    </Grid>
  );
}
```

## In a dialog

Compose Stepper inside [Dialog](/components/dialog/). Keep the dialog's own step state as the stepper `value`, and disable steps the person has not reached so they cannot skip ahead.

```tsx
import { Button, Dialog, Stepper, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function StepperDialogExample() {
  const [step, setStep] = useState(1);
  const steps = [
    { body: "Name the workspace and choose who can see it.", step: 1, title: "Details" },
    { body: "Invite the people who will work here.", step: 2, title: "Members" },
    { body: "Review the details, then create the workspace.", step: 3, title: "Review" },
  ] as const;
  const current = steps[step - 1];

  return (
    <Dialog.Root>
      <Dialog.Trigger variant="primary">Create workspace</Dialog.Trigger>
      <Dialog.Content>
        <Dialog.Header>
          <Dialog.Title>Create workspace</Dialog.Title>
          <Dialog.Description>Set up a shared place for the team.</Dialog.Description>
        </Dialog.Header>
        <Stepper
          aria-label="Create workspace"
          density="compact"
          value={step}
          onValueChange={setStep}
        >
          {steps.map((item, index) => (
            <Stepper.Item key={item.step} disabled={item.step > step} step={item.step}>
              <Stepper.Trigger>
                <Stepper.Indicator />
                <Stepper.Title>{item.title}</Stepper.Title>
              </Stepper.Trigger>
              {index < steps.length - 1 ? <Stepper.Separator /> : null}
            </Stepper.Item>
          ))}
        </Stepper>
        {current ? <Text color="subtle">{current.body}</Text> : null}
        <Dialog.Footer>
          <Button
            variant="primary"
            disabled={step === 1}
            onClick={() => setStep((value) => value - 1)}
          >
            Back
          </Button>
          {step < steps.length ? (
            <Button onClick={() => setStep((value) => value + 1)}>Next</Button>
          ) : (
            <Dialog.Close variant="primary">Create</Dialog.Close>
          )}
        </Dialog.Footer>
      </Dialog.Content>
    </Dialog.Root>
  );
}
```

## Variants

outline, solid

## Anatomy

```text
Stepper
Stepper.Item
Stepper.Trigger
Stepper.Indicator
Stepper.Title
Stepper.Description
Stepper.Separator
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| value / defaultValue / onValueChange | number / number / (value: number) => void | — | The active step, controlled or uncontrolled. Steps are 1-based. |
| orientation | horizontal \| vertical | horizontal | Lays steps in a row, or stacks them with the connector in the indicator column. |
| variant | outline \| solid | outline | Outline keeps upcoming steps quiet, marks the active step as selected, and fills a completed step with the primary brand color. Solid fills every indicator with that color. |
| density | comfortable \| compact | comfortable | Scales the indicator and type. Inherits from DensityProvider when omitted. |
| Item.step | number | — | The step this item represents. State is derived by comparing it with value. |
| Item.disabled | boolean | false | Blocks selection and mutes the step. |
| Item.loading | boolean | false | Replaces the indicator content with a spinner. Use it on the active step. |
| className | string | — | Merged last on every part. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

The root is a `group` and exposes `aria-orientation`. Give it an `aria-label` when the surrounding heading does not name the sequence.

`Stepper.Trigger` is a button. The active trigger sets `aria-current="step"`. A disabled item disables its trigger, so it stays in the tab order's skipped set and cannot be activated from the pointer or the keyboard. The indicator's check and spinner are decorative; the title carries the step name.

`Stepper.Separator` is hidden from assistive technology. Do not rely on the connector alone to communicate progress.

Source: https://zenos-ui.pages.dev/components/stepper/