Skip to content
English

How it works

Steps have equal width, so line positions are percentages with no measuring: each line lives in the later step, reaches left to the previous dot, and fills with scaleX. All layers of a dot stay in the DOM and only data-state changes, so forward, back and error can interrupt each other. Two delay variables stage the motion: the line arrives first, then the dot lights up, and multi-step jumps relay segment by segment. A clickable step gets a transparent button laid over it instead of a tag swap.

Use it for

  • Linear flows of 3–5 steps such as checkout, sign-up or verification, so people know how many steps there are and where they are.
  • At the top of a multi-step form, with Back and Next, letting people click finished steps to edit them.
  • Read-only progress through fixed stages such as order, support or review status.

Look elsewhere when

  • More than 5 steps or long titles: they truncate; use a vertical timeline or “Step 2 of 8” text.
  • Steps that can be visited in any order: that is tabs.
  • A percentage such as an upload: use a progress bar or ring.

Usage

import { useState } from 'react'
import { StepProgress } from './StepProgress.jsx'

const STEPS = [
  { title: 'Choose item', description: 'Trail sneakers' },
  { title: 'Review order' },
  { title: 'Pay' },
  { title: 'Done' },
]

export function Checkout() {
  const [current, setCurrent] = useState(0)
  const [failed, setFailed] = useState(false)
  const done = current === STEPS.length - 1
  return (
    <StepProgress
      aria-label="Checkout progress"
      steps={STEPS}
      current={current}
      status={failed ? 'error' : done ? 'finish' : 'process'}
      // Without it the stepper is display-only; with it, finished steps can be clicked to go back
      onStepClick={setCurrent}
    />
  )
}

Props

PropTypeDefaultWhat it does
steps{ title, description? }[]—The steps. title is one line and truncates if it does not fit; description takes up to two lines.
currentnumber0Current step, starting at 0. Out-of-range values are clamped to the first or last step.
status'process' | 'error' | 'finish''process'Status of the current step: in progress, error (danger color and a cross), or all done (the current step is checked too).
onStepClick(index: number) => void—When set, finished steps become clickable buttons that report their index, for going back to edit. The current and upcoming steps are not clickable.
size'sm' | 'md''md'md: 28px dot and 13px title; sm: 22px dot and 12px title, for narrow phone screens.
labels{ done, current, todo, error }{ done: 'Completed', current: 'Current step', todo: 'Not started', error: 'Error' }Screen-reader status text read after each step. Replace it to localize; missing keys keep the English default.
...restOlHTMLAttributes—Other attributes, such as aria-label, className and style, go to the root <ol>.

Accessibility

  • The root is an <ol> with an explicit role="list" (Safari drops list semantics when markers are removed); the current <li> has aria-current="step".
  • Each step has screen-reader status text (Completed, Current step, Not started, Error), replaceable through labels; the number and icons are aria-hidden.
  • A clickable step is a real <button> named from title and status; after a click the step becomes current, the button goes away and focus moves to its <li>, not the page start.
  • The button extends 6px above and below, so even the small size has a click area over 44px tall.
  • State never relies on color alone: done is a check, error a cross, current a bold ring with its number.
  • Reduced motion skips fills, drawing, bursts and shaking; states switch directly.

Motion

Line fill 360ms ease-in-out on a 4px rounded track (retract 240ms); the done disc pops from 40% with a 360ms spring and the check draws in 360ms while scaling from 60% with the same spring; the halo bursts once in 560ms. The new dot lights 220ms after the line starts, multi-step jumps stagger 180ms per segment; going back uses 140ms and 100ms. The error dot shakes for 360ms.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

StepProgress.jsxstep-progress.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Navigation