Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Steps for React Aria

An ordered flow with numbered markers, Back and Next, and the current step's content. A React stepper for wizards and checkouts, used with React Aria.

On this page9 sections

React Aria does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

Steps lay out an ordered flow as a row of numbered markers, with the current step's content under them and Back and Next to move along: a signup, a checkout, an onboarding wizard. Reach for them when each step builds on the one before.

For views with no order, use Tabs. To show how far a single task has run, with nothing to visit, a Progress bar is enough. Steps runs on Ark UI's steps machine on every base, so the file imports @ark-ui/react next to React Aria.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Steps anatomy: list, indicator, separator, content, previous, next

Usage

import { Button } from "@/components/ui/button";
import {
  Steps, StepsCompletedContent, StepsContent, StepsIndicator, StepsItem,
  StepsList, StepsNext, StepsPrevious, StepsSeparator, StepsTitle,
  StepsTrigger,
} from "@/components/ui/steps";

count is the number of steps, and each StepsItem and StepsContent takes an index from 0. StepsCompletedContent shows after Next is pressed on the last step.

const titles = ["Account", "Profile", "Review"];

export const SignupSteps = () => (
  <Steps className="w-full max-w-md" count={titles.length}>
    <StepsList>
      {titles.map((title, index) => (
        <StepsItem index={index} key={title}>
          <StepsTrigger>
            <StepsIndicator>{index + 1}</StepsIndicator>
            <StepsTitle>{title}</StepsTitle>
          </StepsTrigger>
          <StepsSeparator />
        </StepsItem>
      ))}
    </StepsList>
    {titles.map((title, index) => (
      <StepsContent index={index} key={title}>
        The {title.toLowerCase()} fields go here.
      </StepsContent>
    ))}
    <StepsCompletedContent>You're signed up.</StepsCompletedContent>
    <div className="flex justify-between gap-2">
      <StepsPrevious asChild>
        <Button variant="outline">Back</Button>
      </StepsPrevious>
      <StepsNext asChild>
        <Button>Next</Button>
      </StepsNext>
    </div>
  </Steps>
);

Accessibility

Ark UI makes the list a tablist and each trigger a tab, with aria-selected on the current step's trigger and aria-current on its StepsItem. Each step's content is a tabpanel labelled by its trigger, and the list is a single tab stop. Two things are left to you. The indicator is hidden from screen readers, so a trigger needs a StepsTitle or an aria-label to have a name. And nothing announces a new step, so after Next, move focus to the new step's heading or first field.

Tab
Moves focus onto the list's one stop: the current step's trigger, or the last trigger once every step is done. Step content is not a tab stop.
Arrow Right
In a horizontal list, moves focus to the next enabled trigger, wrapping from the last to the first. In a right-to-left list it moves to the previous one.
Arrow Left
In a horizontal list, moves focus to the previous enabled trigger, wrapping from the first to the last. In a right-to-left list it moves to the next one.
Arrow Down
In a vertical list, moves focus to the next enabled trigger, wrapping around.
Arrow Up
In a vertical list, moves focus to the previous enabled trigger, wrapping around.
Home
Moves focus to the first enabled trigger.
End
Moves focus to the last enabled trigger.
Enter
Opens the focused trigger's step, unless linear is set or isStepValid holds the current step back. The arrow keys only move focus.
Space
Opens the focused trigger's step, unless linear is set or isStepValid holds the current step back.

Demos

Controlled

Three steps, Your details, Company details and Invite your team, with Back, Next and Reset buttons of the page's own below them. The index lives in the page's state, passed as step and updated from onStepChange, so a click on a trigger and the buttons change the same value. Control it when something outside the wizard decides the step, such as a saved draft or a URL parameter.

Preview width

Description

Each trigger holds a number, a title and a one-word description under it: Info over Personal, Docs over Company, Team over Create. The row then says what each step covers before anyone opens it. Keep the description to a word or two, because a sentence wraps inside the trigger and squeezes the separators between steps.

Preview width

Icon

A person, a drive and a credit card stand in for the numbers, for account, storage and payment. The icons are hidden from screen readers just as numbers would be, so each StepsTrigger carries an aria-label, Account, Storage or Payment, to give it a name. Pick icons when each step is something people recognize at a glance.

Preview width

Loading

The first indicator spins in place of its number, and every StepsTrigger is disabled, so no click or arrow key can move off a step while it saves or checks. The spinner is hidden from screen readers with the rest of the indicator, so the first trigger's aria-label says the step is loading. Put the loader in the indicator, and turn the triggers back on once the check finishes.

Preview width

Title

A number and a one-word name for each step: Info, Docs and Team. StepsTitle in the trigger is the smallest label that tells people what comes next, and it gives the trigger its accessible name, since the number is hidden from screen readers. Use it whenever position alone doesn't explain the sequence.

Preview width

Vertical

Info, Docs and Team run down the side with orientation set to vertical on Steps, each separator a line from one indicator to the next. The current step's content sits beside the list with Back and Next under it, and a Completed panel replaces it after the last step. Use it beside a preview, and keep the row across the top of a short form.

Preview width

FAQ

How do I build a multi-step form wizard with Steps in React?

Set count on Steps to the number of steps, give each StepsItem and StepsContent an index from 0, and put each step's fields in its StepsContent. StepsPrevious and StepsNext are the Back and Next buttons: Back is disabled on the first step, and Next on the last step shows StepsCompletedContent.

Wrap the whole of Steps in one form. Every StepsContent stays rendered and is only hidden while its step isn't current, so fields keep their values as people go back and forth and all of them submit together. Back and Next are type="button", so a submit button of your own goes on the last step.

How do I control the current step of Steps from state?

Hold the index in state, pass it as step on Steps and update it in onStepChange. The callback receives an object, so read the new index from details.step, as the Controlled demo does.

The index starts at 0, and a value equal to count means every step is done, which shows StepsCompletedContent. To start on another step without holding the state yourself, set defaultStep.

How do I stop Steps from moving forward until a step is valid?

Pass isStepValid to Steps: a function that takes a step's index and returns whether that step is complete. Next and a click on a later trigger both check the current step, and when it returns false the step stays put and onStepInvalid is called, so you can show the errors there.

Going back is never checked. Only the current step is, so a valid first step lets a click on the last trigger jump past the steps in between. Set linear as well when every step must be filled in order.

Can users skip ahead to a later step in Steps?

By default they can. Every trigger is a button, and clicking one, or pressing Enter on it, opens that step as long as isStepValid lets the current one go. Set linear on Steps and the triggers stop responding to clicks altogether, going back included, so people move only with Back and Next.

isStepSkippable marks a step optional. It takes an index, and while it returns true for the current step, Next moves on without asking isStepValid.

How do I show Steps vertically?

Set orientation to vertical on Steps. The root becomes a row at least 128px tall, the list stacks its steps down the side with a separator running from each indicator to the next, and the content fills the space beside the list.

The Vertical demo puts the content, Back and Next in one column next to the list. The Up and Down arrow keys then move between triggers, in place of Left and Right.

How do I style completed and current steps?

Each StepsTrigger, StepsIndicator and StepsSeparator carries its step's state: data-complete before the current step, data-current on it and data-incomplete after it. Target them with classes such as data-complete:bg-primary, or change the defaults in components/ui/steps, where a completed indicator fills with the primary color and swaps its number for a check.

Sizes are CSS variables on StepsList: --steps-size for the indicator, --steps-icon-size for an icon in it and --steps-gutter for the space around each separator.

Do screen readers announce the current step in Steps?

Partly. The current step's trigger is the selected tab and its item carries aria-current, so moving through the list says which step is current. The number or icon in StepsIndicator is hidden from screen readers, though, so a trigger with only an indicator has no name: add a StepsTitle, or an aria-label on StepsTrigger as the Icon demo does.

Nothing is announced when Next is pressed, and focus stays on the button, or falls back to the page after the last step, when Next turns disabled. Once the new step shows, move focus to its heading or first field from your code. StepsContent is out of the tab order but can take focus that way.

Should I use Steps, Tabs or a Progress bar?

Use Steps when the order matters: each step builds on the one before, people move with Back and Next, and the row of markers shows how far they've come, as in a signup, a checkout or an onboarding flow.

Tabs are for peer views with no order, where any panel can open at any time. A Progress bar fits one task that advances on its own, such as an upload or an import, with no steps for people to visit.

API Reference

Steps

<div> data-slot="steps"

PropType
step?number

The controlled value of the stepper.

defaultStep?number

The initial value of the stepper when rendered. Use when you don't need to control the value of the stepper.

onStepChange?(details: StepChangeDetails) → void

Callback to be called when the value changes.

Type
(details: StepChangeDetails) → void
Parameters

details – { step: number }

Returns
void
count?number

The total number of steps.

dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
id?string

The unique identifier of the machine.

ids?object

The custom ids for the stepper elements.

Type
{ root?: string; list?: string; triggerId?: (index: number) → string; contentId?: (index: number) → string }
isStepSkippable?(index: number) → boolean

Whether a step can be skipped during navigation. Skippable steps are bypassed when using next/prev.

Default
() => false
Parameters

index – number

Returns
boolean
isStepValid?(index: number) → boolean

Whether a step is valid. Invalid steps block forward navigation in linear mode.

Default
() => true
Parameters

index – number

Returns
boolean
linear?boolean

If true, the stepper requires the user to complete the steps in order.

onStepComplete?VoidFunction

Callback to be called when a step is completed.

onStepInvalid?(details: StepInvalidDetails) → void

Called when navigation is blocked due to an invalid step.

Type
(details: StepInvalidDetails) → void
Parameters

details – { step: number; action: "next" | "set"; targetStep?: number }

Returns
void
orientation?"horizontal" | "vertical"

The orientation of the stepper.

Type
"horizontal" | "vertical"
Default
"horizontal"
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

The orientation of the steps.

Type
"horizontal" | "vertical"
CSS variableType
--percentstring

The percent value for the Root.

StepsList

<div> data-slot="steps-list"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

The orientation of the list.

Type
"horizontal" | "vertical"

StepsItem

<div> data-slot="steps-item"

PropType
indexnumber

The item's position in its list.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

The orientation of the item.

Type
"horizontal" | "vertical"
data-skippable?string

Present when skippable is true.

StepsTrigger

<button> data-slot="steps-trigger"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-complete?string

Present when the trigger value is complete.

data-current?string

Present when current.

data-incomplete?string

Present when incomplete is true.

data-orientation"horizontal" | "vertical"

The orientation of the trigger.

Type
"horizontal" | "vertical"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

StepsIndicator

<div> data-slot="steps-indicator"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-complete?string

Present when the indicator value is complete.

data-current?string

Present when current.

data-incomplete?string

Present when incomplete is true.

CSS variableType
--steps-icon-sizestring
--steps-sizestring

StepsSeparator

<div> data-slot="steps-separator"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-complete?string

Present when the separator value is complete.

data-current?string

Present when current.

data-incomplete?string

Present when incomplete is true.

data-orientation"horizontal" | "vertical"

The orientation of the separator.

Type
"horizontal" | "vertical"
CSS variableType
--steps-gutterstring
--steps-sizestring

StepsContent

<div> data-slot="steps-content"

PropType
indexnumber

The content's position in its list.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

The orientation of the content.

Type
"horizontal" | "vertical"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

StepsNext

<button> data-slot="steps-next"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

StepsPrevious

<button> data-slot="steps-previous"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

StepsTitle

<span> data-slot="steps-title"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

Mirrors the orientation prop.

Type
"horizontal" | "vertical"

StepsDescription

<span> data-slot="steps-description"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-orientation"horizontal" | "vertical"

Mirrors the orientation prop.

Type
"horizontal" | "vertical"

StepsCompletedContent

<div> data-slot="steps-completed-content"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

useSteps

PropType
step?number

The controlled value of the stepper.

defaultStep?number

The initial value of the stepper when rendered. Use when you don't need to control the value of the stepper.

onStepChange?(details: StepChangeDetails) → void

Callback to be called when the value changes.

Type
(details: StepChangeDetails) → void
Parameters

details – { step: number }

Returns
void
count?number

The total number of steps.

id?string

The unique identifier of the machine.

ids?object

The custom ids for the stepper elements.

Type
{ root?: string; list?: string; triggerId?: (index: number) → string; contentId?: (index: number) → string }
isStepSkippable?(index: number) → boolean

Whether a step can be skipped during navigation. Skippable steps are bypassed when using next/prev.

Default
() => false
Parameters

index – number

Returns
boolean
isStepValid?(index: number) → boolean

Whether a step is valid. Invalid steps block forward navigation in linear mode.

Default
() => true
Parameters

index – number

Returns
boolean
linear?boolean

If true, the stepper requires the user to complete the steps in order.

onStepComplete?VoidFunction

Callback to be called when a step is completed.

onStepInvalid?(details: StepInvalidDetails) → void

Called when navigation is blocked due to an invalid step.

Type
(details: StepInvalidDetails) → void
Parameters

details – { step: number; action: "next" | "set"; targetStep?: number }

Returns
void
orientation?"horizontal" | "vertical"

The orientation of the stepper.

Type
"horizontal" | "vertical"
Default
"horizontal"