Stepper
A multi-step wizard component with validation.
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/stepperInstall the following dependencies:
npm install lucide-react radix-uinpx shadcn@latest add @formance/spinnerCopy 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 hascompleted.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#
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The identifier of the step. |
completed | boolean | false | Marks the step as completed, also when it is after the current step. |
disabled | boolean | false | Prevents the selection of the step. |
status | "running" | "failed" | "paused" | - | Overrides the state of the step. It wins over completed and over value. |
asChild | boolean | false | Render the child as the item. |
StepperIndicator#
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((state: string) => ReactNode) | - | Replaces the default content: the step number, a check, a spinner, an X or a pause icon. |
className | string | - | More classes for the indicator. |
data-state#
| Value | When |
|---|---|
inactive | The step is after the current step. |
active | The step is the current step. The separator is inactive. |
completed | The step is before the current step, or it has completed. |
running | The step has status="running". |
failed | The step has status="failed". |
paused | The 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).