Stepper
Shows where the user is in a multi-step task and lets them move between steps, in a row or a column.
Select a step, or use the buttons below to move. Done steps show a check.
When to use
- For a task with a fixed order of stages, such as creating a monitoring request or configuring a rule.
- When the user needs to know how much is left, and may go back to a finished step.
- When each stage is a distinct page or panel with its own content.
When not to use
- Sections of one page that the user can visit in any order. Use Tabs.
- A single long form. Use sections with headings.
- Progress of a running job. Use Progress.
- More than about seven steps. Group the stages, or split the task.
- Navigation between unrelated pages. Use the app navigation.
Anatomy
A stepper is built from parts. Number the steps from 1: the indicator prints the number as it is.
| Part | Role |
|---|---|
Stepper |
Holds the active step (value, or defaultValue) and the orientation. |
StepperItem |
One step. Takes step, and optionally completed, disabled and loading. |
StepperTrigger |
The button that activates the step. Wraps the indicator and the texts. |
StepperIndicator |
The circle with the number, a check when done, or a spinner when loading. Set its size with className, for example size-8. |
StepperTitle |
The name of the step. |
StepperDescription |
One short line of context. |
StepperSeparator |
The line between steps. Leave it out after the last step. |
Orientation
horizontal is the default and fits wide pages. vertical fits side panels and steps with long descriptions.
States
A step is done when its number is lower than the active step, or when you pass completed. It is current when it equals the active step, and upcoming otherwise.
Loading
loading shows a spinner on the current step, for example while the step is validated.
Locked
disabled stops a step from being activated. Use it for steps the user has not reached yet.
Content
- Titles name the stage in one to three words: “Dados do processo”, “Documentos”, “Revisão”.
- Descriptions say what the user does there, in under six words.
- Keep the same names in the page title of each step.
- Do not put the step count in the title. The indicator already shows it.
Do and don’t
Accessibility
- Each step trigger is a real
button(typebutton).Tabreaches it,EnterandSpaceactivate it. - The current step has
aria-current="step". A loading step hasaria-busy="true". - A disabled step is a disabled button and is skipped by
Tab. WithasChildit getsaria-disabledinstead. - The focus ring uses the
focustoken withfocus-visible. - The check and the spinner are
aria-hidden. The state of a done step is not spoken: it is shown only by the check. Add visually hidden text such as “concluída” inside the trigger when the state matters. - Titles are
h3and descriptions arep. Put the stepper under a matching heading level, or the page outline will skip a level. - With motion reduced, the check and spinner animations stop.
Code
import {
Stepper,
StepperDescription,
StepperIndicator,
StepperItem,
StepperSeparator,
StepperTitle,
StepperTrigger,
} from "@repo/ui/stepper";
<Stepper defaultValue={1}>
<StepperItem className="flex-1" step={1}>
<StepperTrigger>
<StepperIndicator className="size-8" />
<div className="flex flex-col items-start">
<StepperTitle>Dados do processo</StepperTitle>
<StepperDescription>Número do processo e cliente</StepperDescription>
</div>
</StepperTrigger>
<StepperSeparator className="mx-3" />
</StepperItem>
<StepperItem step={2}>
<StepperTrigger>
<StepperIndicator className="size-8" />
<StepperTitle>Documentos</StepperTitle>
</StepperTrigger>
</StepperItem>
</Stepper>;
Props
Stepper| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | number | 0 | Initial active step when the stepper is uncontrolled |
onValueChange | (value: number) => void | — | Called with the step number when the user picks a step |
orientation | "horizontal" | "vertical" | "horizontal" | Direction the steps are laid out |
value | number | — | Controlled active step |
StepperItem| Prop | Type | Default | Description |
|---|---|---|---|
step | number | — | Number of this step. Shown in the indicator, so start at 1. |
completed | boolean | false | Marks the step as done even when it is not before the active one. |
disabled | boolean | false | Stops the trigger from activating the step. |
loading | boolean | false | Shows a spinner in the indicator. Only applies while the step is the active one. |
StepperTrigger| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Renders the child element instead of a button. The child gets the step styles and behavior. |
disabled | boolean | false | Disables this trigger, on top of the `disabled` prop of the item. |
StepperIndicator| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Renders your own content inside the circle instead of the number, check and spinner. |
StepperTitle, StepperDescription and StepperSeparator only take className and standard element attributes.
Known issues
| Issue | Effect |
|---|---|
Active and completed indicators use text-primary-foreground, which is not a token of the Tailwind preset (it defines old-primary). |
The class generates no style, so the number and the check keep text-primary on the bg-inverse circle. Check the contrast in Light and Dark. |
defaultValue is 0 and the indicator prints step as it is. |
A zero-based step shows “0” in the first circle. Number the steps from 1 and set defaultValue={1}. |
StepperIndicator has no width or height. |
Without a size-* class the circle collapses to the number. Every call site has to set the size. |
Disabled triggers use disabled:opacity-50 and aria-disabled:opacity-50. |
Opacity-based disabled state, which the repository avoids. Contrast drops below the minimum for text. |
Stepper is a div with no role or label, and the titles are h3. |
Assistive technology does not announce a list of steps, and the headings can break the page outline. |