Skip to content

Stepper

Shows a task that is done in a few steps, in order: what is finished, where the person is, and what is left.

import { Stepper } from '@sypnia/ui/react'

On this page
  1. Done, current and to do
  2. Moving through it
  3. At the start and finished
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

Done, current and to do

The second of four steps.

  1. Upload the file
  2. Match columns
  3. Review
  4. Import
Code
import { Stepper } from '@sypnia/ui/react';

// Done, current and to do. On a phone only the current step shows its name.
export default function Basic() {
  return <Stepper label="Import a CSV file" steps={['Upload the file', 'Match columns', 'Review', 'Import']} current={1} />;
}

Moving through it

Press «Continue» and «Back».

  1. Name the project
  2. Choose a region
  3. Invite the team
Code
import { useState } from 'react';
import { Actions, Alert, Button, Field, Input, Stepper } from '@sypnia/ui/react';

const steps = ['Name the project', 'Choose a region', 'Invite the team'];
// Press «Continue» and «Back»: the light moves with you.
export default function Walkthrough() {
  const [step, setStep] = useState(0);
  const done = step === steps.length;
  return (
    <div className="sy-stack">
      <Stepper label="Create a project" steps={steps} current={step} />
      {done
        ? <Alert tone="ok" title="The project is ready">Its first table is one press away.</Alert>
        : <Field label={steps[step]}><Input key={step} placeholder={['Storefront', 'Frankfurt', 'diego@northwind.io'][step]} /></Field>}
      <Actions>
        <Button disabled={step === 0} onClick={() => setStep(step - 1)}>Back</Button>
        <Button variant="primary" disabled={done} onClick={() => setStep(step + 1)}>{step === steps.length - 1 ? 'Create project' : 'Continue'}</Button>
      </Actions>
    </div>
  );
}

At the start and finished

Nothing done yet, and everything done.

  1. Upload the file
  2. Match columns
  3. Review
  4. Import
  1. Upload the file
  2. Match columns
  3. Review
  4. Import
Code
import { Stepper } from '@sypnia/ui/react';

// The first step, and all of them done.
export default function Ends() {
  const steps = ['Upload the file', 'Match columns', 'Review', 'Import'];
  return (
    <div className="sy-stack">
      <Stepper label="Import, at the start" steps={steps} current={0} />
      <Stepper label="Import, finished" steps={steps} current={4} />
    </div>
  );
}

Skeleton

The real piece and its skeleton: the same box, so nothing moves when the data arrives.

  1. Choose the source
  2. Credentials
  3. Tables
  4. Review
Code
import { Stepper, StepperSkeleton } from '@sypnia/ui/react';

// While the steps of a task load: the same bars, without names.
export default function Skeleton() {
  return (
    <div className="sy-stack">
      <Stepper label="Connect a database" current={1} steps={['Choose the source', 'Credentials', 'Tables', 'Review']} />
      <StepperSkeleton steps={4} />
    </div>
  );
}

When to use it

Use it when

  • A task of three to five steps that must be done in order: import a file, create a project.
  • Above the content of the current step, with «Back» and «Continue» in Actions under it.

Do not use it when

  • The parts can be visited in any order: Tabs.
  • There are two steps: a form and its confirmation need no map.
  • It measures how much of a task the machine has done: Progress.
  • Step names are long. Two or three words each.

For everyone

  • It is an ordered list with a name (label). The current step is marked aria-current="step".
  • Each step is numbered in text, so the order does not depend on position or colour.
  • The steps are not buttons: moving happens with the «Back» and «Continue» buttons of the form.
  • On phones only the current step shows its name; the others keep their bar.

Props

StepperTypeDefault
currentrequired number
labelrequired string
stepsrequired string[]
  1. Done, current and to do
  2. Moving through it
  3. At the start and finished
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

    Search pages, sections and terms