# Stepper API

> Explore the API of Cimpress UI's stepper component.

Source: https://ui.cimpress.io/components/stepper/api/

## Import

```tsx
import { UNSTABLE_Stepper, UNSTABLE_StepperItem } from '@cimpress-ui/react';
```

## Usage notes

A `Stepper` consists of multiple `StepperItem` components, each representing a single step in the process. Place each `StepperItem` as a child of the `Stepper`.

By default, `Stepper` will automatically set the status of each `StepperItem` based on its index: steps before the current step (`currentStep`) are marked as `complete`, the current step as `in-progress`, and any remaining steps as `incomplete`. You can override this by providing a `status` prop directly to a step (e.g., `complete`, `warning`, or `error`).

To make the stepper interactive, provide an `onChange` handler to the `Stepper`. Make sure to update the `currentStep` prop when the `onChange` handler is called. Users can only select steps that precede the current step, or any step with an explicit `status` prop.

## API reference

### Stepper

Displays a series of steps in a process.

- `ref`: `Ref<HTMLDivElement>`

  The `ref` type for this component.

**Props: `UNSTABLE_StepperProps`**

- `children` (required): `ReactNode`

  The steps to display in the stepper.

- `currentStep`: `number`

  The index of the active step.

- `onChange`: `(step: number) => void`

  The callback to call when the current step changes.

- `orientation`: `'vertical' | 'horizontal'`

  The orientation of the stepper.

  Defaults to `'horizontal'`.

- `id`: `string`

  The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

- `data-cim-style-root`: `boolean`

  Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.

- `UNSAFE_className`: `string`

  Sets the CSS className for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).

- `UNSAFE_style`: `CSSProperties`

  Sets the CSS style for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).

**Props: `StyleProps`**

- `margin`: `Responsive<Spacing | "auto">`

  The amount of margin applied to all edges of this component.

- `marginX`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the left and right edges of this component. Takes priority over `margin`.

- `marginY`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the top and bottom edges of this component. Takes priority over `margin`.

- `marginTop`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the top edge of this component. Takes priority over `marginY` and `margin`.

- `marginRight`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the right edge of this component. Takes priority over `marginX` and `margin`.

- `marginBottom`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the bottom edge of this component. Takes priority over `marginY` and `margin`.

- `marginLeft`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the left edge of this component. Takes priority over `marginX` and `margin`.

### StepperItem

Represents a single step in a stepper component.

**Props: `UNSTABLE_StepperItemProps`**

- `children` (required): `StringLikeChildren`

  The title of the step.

- `description`: `ReactNode`

  The description of the step. Optionally, you can pass a React node to render rich text.

- `status`: `StepperStatus`

  The status of the step.

- `id`: `string`

  The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

- `data-cim-style-root`: `boolean`

  Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.

- `UNSAFE_className`: `string`

  Sets the CSS className for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).

- `UNSAFE_style`: `CSSProperties`

  Sets the CSS style for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).
