Atoms

Stepper

A multi-step wizard component with validation.

Formance
Docs

Vertical#

Set orientation="vertical" to stack the steps beside the content. Arrow up and down move between the steps.

Guide#

A static list of numbered steps, each with its command. Set nonInteractive and leave value unset: every step stays inactive, so none looks done.

Checklist#

Each step unlocks the next once it is confirmed. Pass your own icons to StepperIndicator for the locked and done states, and put the separator in a column next to the text.

Summary#

A read-only list of what is left to do, inside an empty state. Only the first step is current.

Workflow status#

Show the progress of a long task, for example a deployment. Set status on the current StepperItem to "running", "failed" or "paused". Set value to the current step: the steps before it are completed, and the steps after it are inactive.

Installation#

npx shadcn@latest add @formance/stepper

Install the following dependencies:

npm install lucide-react radix-uinpx shadcn@latest add @formance/spinner

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Usage#

import {  Stepper,  StepperContent,  StepperDescription,  StepperIndicator,  StepperItem,  StepperList,  StepperNextTrigger,  StepperPrevTrigger,  StepperSeparator,  StepperTitle,  StepperTrigger,} from '@/components/ui/stepper'
<Stepper defaultValue="account">  <StepperList>    <StepperItem value="account">      <StepperTrigger>        <StepperIndicator />        <StepperTitle>Account</StepperTitle>      </StepperTrigger>      <StepperSeparator />    </StepperItem>    <StepperItem value="ledger">      <StepperTrigger>        <StepperIndicator />        <StepperTitle>Create Ledger</StepperTitle>      </StepperTrigger>      <StepperSeparator />    </StepperItem>    <StepperItem value="review">      <StepperTrigger>        <StepperIndicator />        <StepperTitle>Review</StepperTitle>      </StepperTrigger>    </StepperItem>  </StepperList>
  <StepperContent value="account">Configure your account.</StepperContent>  <StepperContent value="ledger">Create your first ledger.</StepperContent>  <StepperContent value="review">Review and confirm.</StepperContent></Stepper>

Status#

A step gets its state from value and completed:

  • completed: the step is before the current step, or it has completed.
  • active: the step is the current step.
  • inactive: the step is after the current step.

A task that runs for a long time needs more states. Set status on a StepperItem to override the state of that step:

  • "running": the step runs. The indicator shows a spinner.
  • "failed": the step stopped on an error. The indicator is red and shows an X.
  • "paused": the step waits, for example for an approval. The indicator is muted and shows a pause icon.

The item, the trigger, the indicator and the separator get the status in data-state. Use it to style other parts, for example group-data-[state=failed]/step:text-destructive-foreground. The separator after a step with a status is not colored, because the step is not complete.

The icons do not give the status to a screen reader. Write the status in text too, for example "Stopped on error" next to the title.

Description and time#

For a vertical rail, put the indicator and the separator in one column, and the text in a second column. Put the time in the title row, after StepperTitle. Put StepperDescription below the title row. You do not need a new part for the time.

<StepperItem value="schema" status="running" className="flex-row items-start gap-3">  <div className="flex flex-col items-center self-stretch">    <StepperTrigger>      <StepperIndicator />    </StepperTrigger>    <StepperSeparator className="my-1 min-h-6 flex-1" />  </div>  <div className="flex min-w-0 flex-1 flex-col gap-0.5 pt-1 pb-5">    <div className="flex items-baseline justify-between gap-4">      <StepperTitle>Store the schema</StepperTitle>      <span className="text-muted-foreground text-xs">In progress</span>    </div>    <StepperDescription>The ledger saves the schema.</StepperDescription>  </div></StepperItem>

API reference#

StepperItem#

PropTypeDefaultDescription
valuestring-The identifier of the step.
completedbooleanfalseMarks the step as completed, also when it is after the current step.
disabledbooleanfalsePrevents the selection of the step.
status"running" | "failed" | "paused"-Overrides the state of the step. It wins over completed and over value.
asChildbooleanfalseRender the child as the item.

StepperIndicator#

PropTypeDefaultDescription
childrenReactNode | ((state: string) => ReactNode)-Replaces the default content: the step number, a check, a spinner, an X or a pause icon.
classNamestring-More classes for the indicator.

data-state#

ValueWhen
inactiveThe step is after the current step.
activeThe step is the current step. The separator is inactive.
completedThe step is before the current step, or it has completed.
runningThe step has status="running".
failedThe step has status="failed".
pausedThe step has status="paused".

Compound Components

Compose the pieces you need:

<Stepper />Root provider with value, orientation, and validation.
<StepperList />Tab list container for step triggers.
<StepperItem />Individual step with value, completed, disabled, and status (running, failed, paused).
<StepperTrigger />Clickable trigger for a step.
<StepperIndicator />Step number, check, spinner, X, or pause icon, styled by state.
<StepperTitle />Label text for a step.
<StepperDescription />Secondary text below the step title.
<StepperSeparator />Line between steps, colored by completion state.
<StepperContent />Panel content shown for the active step.
<StepperPrevTrigger />Button to navigate to the previous step.
<StepperNextTrigger />Button to navigate to the next step (runs validation).