|Kit

Steps

A stepper for multi-step flows on Ark UI's Steps machine — numbered steps joined by connectors that fill as the flow advances, a content panel per step, a completed panel, and Prev/Next buttons.

Steps walks a user through a flow in order: a registration, an exam sign-up, a staff wizard. Each step has an indicator (its number, a check once complete, or your icon), a title and an optional description, and the connectors between steps fill as the flow advances. Each step shows its own content panel, and a completed panel takes over once the last step is done.

import { Steps } from '@42-central/ui-react/steps';

<Steps
  withControls
  data={[
    { title: 'Account', description: 'Email and password', content: <Account /> },
    { title: 'Campus', description: "Where you'll study", content: <Campus /> },
    { title: 'Confirm', content: <Confirm /> },
  ]}
  completed={<Welcome />}
/>

Steps doesn't validate anything. Your app decides when the user may move on: control step and only advance it once the step's form is valid, or pass Ark's isStepValid so Next refuses to move. See Gating Next.

Playground

Component

Loading preview

Props

Code

<Component
  orientation="horizontal"
  size="md"
  linear={false}
  withControls
/>

Steps

data is an array of { title, description?, content?, icon?, error?, disabled?, testId? }. The step is an index: 0 is the first step, and data.length is the completed state, which shows the completed panel.

Set withControls to render Back/Next buttons under the panels. On the last step Next reads "Finish" and completes the flow; once complete, only Back remains. Leave withControls off when your own buttons drive the step.

Choose your campus and your intake.

Each step's trigger gets data-testid={`step-${index}`} (or the item's own testId), its panel `${testId}-panel`. The Back and Next buttons and the completed panel take steps-prev, steps-next and steps-completed, prefixed by the root's testId when you set one. See the Testing guide.

States

A step is upcoming, current or complete, from its position against the current step. Mark one error: true to show a cross in red instead, whatever its position: Ark has no error state of its own, so your app decides when a step has one (a failed server check, a missing document).

Book one of the upcoming Piscine sessions.
Application sent. We'll email you within a week.

Icons

Give a step an icon to show instead of its number. The check replaces it once the step is complete, and the cross on error. Swap those two for the whole stepper with icons={{ complete, error }}.

Code

<StepsIconsExample />

By default any step can be clicked. With linear, only the completed steps (and the current one) can: the steps ahead wait for Next. A completed step stays clickable, so the user can always go back and change an answer. This differs from Ark's own linear, which locks every step. A step with disabled: true can never be clicked.

Choose your campus and your intake.

Gating Next

Control step with onChange and render your own buttons, then only let the user move on once the step is done. Here Next stays disabled until the rules are accepted:

Code

<StepsGatedExample />
const [step, setStep] = useState(0);

<Steps step={step} onChange={setStep} linear data={steps} />
<Button disabled={!isValid(step)} onClick={() => setStep(step + 1)}>Next</Button>

To keep the built-in buttons instead, pass isStepValid={(index) => …}. Next then refuses to leave an invalid step, and onStepInvalid tells you it tried.

Orientation

orientation="vertical" runs the list down the side, with the panels and buttons beside it. The connectors run under the indicators, past descriptions of any length.

Choose your campus and your intake.

Narrow containers

A horizontal list narrower than 30rem keeps only the current step's title and description on screen, so the indicators and connectors still fit a phone. The other titles stay in each step's accessible name. The list measures itself, not the viewport, so the same stepper collapses in a narrow sidebar on a wide screen.

Campus and intake.

Code

<StepsCompactExample />

Sizes

Five sizes, xs through xl, scaling the indicator, the text and the gaps together. The built-in buttons follow the stepper's size.

Code

<StepsSizesExample />

Colors

Without a color, the stepper uses the default palette. With one, the current step's wash, the completed fills and the connectors' progress take it. color lands on Steps.List only, so a Button inside a panel keeps its own palette. The built-in Next button takes it too.

Code

<StepsColorsExample />

Compound API

Drop to the parts for anything the data array can't express: custom trigger content, panels elsewhere on the page, your own footer. size, color, linear, translations and icons live on Steps.Root, which needs a count.

The profile step.
1 / 3

Code

<StepsCompoundExample />
'use client';
import { Steps } from '@42-central/ui-react/steps';

<Steps.Root count={3} color="green">
  <Steps.List>
    {titles.map((title, index) => (
      <Steps.Item key={title} index={index}>
        <Steps.Trigger>
          <Steps.Indicator />
          <Steps.Title>{title}</Steps.Title>
          <Steps.Description>Optional</Steps.Description>
        </Steps.Trigger>
        <Steps.Separator />
      </Steps.Item>
    ))}
  </Steps.List>
  {titles.map((title, index) => (
    <Steps.Content key={title} index={index}>…</Steps.Content>
  ))}
  <Steps.CompletedContent>Submitted.</Steps.CompletedContent>
  <Steps.PrevTrigger />
  <Steps.NextTrigger />
</Steps.Root>

Steps.Root lays its children out in a column when horizontal and in a row when vertical; wrap the panels in your own element in a vertical stepper so they stack beside the list.

Anatomy

  • Steps.Root — the Ark machine (count, step / defaultStep, onStepChange, isStepValid), the kit's size / color / linear / translations / icons, and the screen-reader announcer.
  • Steps.List — the row (or column) of steps; carries the color.
  • Steps.Item — one step, with its index, and error / disabled.
  • Steps.Trigger — the step's button, around its indicator and text.
  • Steps.Indicator — the round marker: number, check, cross, or its children as a custom icon.
  • Steps.Title / Steps.Description — the step's text.
  • Steps.Separator — the connector to the next step; renders nothing on the last.
  • Steps.Content / Steps.CompletedContent — a step's panel, and the one shown once complete.
  • Steps.PrevTrigger / Steps.NextTrigger — kit Buttons that move back and forward.
  • Steps.Context — a render prop with Ark's API (value, count, setStep, goToNextStep…).

Every part takes its own testId prop, rendered as data-testid on that part.

API

Prop

Type

Steps.Item props (beyond Ark's Steps.Item):

Prop

Type

Steps.PrevTrigger and Steps.NextTrigger take every Button prop. Prev defaults to variant="outline", both to the stepper's size, and their label to the translation when they have no children.

Translations

Prop

Type

Accessibility

  • Built on Ark UI's Steps machine: the list is a tablist, each step's trigger a tab with aria-selected and aria-controls, each panel a tabpanel, and the current step's item carries aria-current="step".
  • The indicator is decorative. A completed or errored step adds "Completed" or "Has errors" to its trigger's name, so the state doesn't rest on the check, the cross or the colour.
  • A polite live region announces "Step 2 of 4" when the step changes, and "All steps completed" at the end: the panel swaps under a Next button that keeps focus, and nothing else would tell a screen-reader user it moved. It stays silent on the first render.
  • A step that can't be clicked (disabled, or ahead under linear) is a disabled button, out of the tab order.
  • Under RTL (from the locale, see Internationalization) the steps run right to left and the connectors fill from the right. The numbers use the locale's digits.
  • The connectors fill over --duration-normal; under prefers-reduced-motion: reduce they switch at once.

Changelog

v0.30.0
  • New Steps: a stepper for multi-step flows, with error steps, linear locking, built-in Back/Next buttons and a vertical orientation

    #479

On this page