Skip to the content
human-kit design
41 — Navigation

Stepper

The steps of a process and where it stands: done, current and ahead, in a row or a column.

  1. Stimulation , completed
  2. Retrieval , completed
  3. Fertilisation
  4. Transfer , not started
Third

Installation

pnpm dlx @human-kit/design add stepper
npx @human-kit/design add stepper
yarn dlx @human-kit/design add stepper
bunx @human-kit/design add stepper

The command copies the files to src/lib/components/ui/stepper. It also installs the packages that the files import.

Usage

<script lang="ts">
	import * as Stepper from '$lib/components/ui/stepper';

	const steps = [{ label: 'Stimulation' }, { label: 'Retrieval' }, { label: 'Transfer' }];
</script>

<Stepper.Root {steps} current={1} />

Examples

Variants

Two ways to draw the steps ahead. outline, the default, stands each one on the edge of a control; filled lays it on a soft grey with no edge, as the filled fields and buttons are. The steps done and the current one are the same in both.

  1. Stimulation , completed
  2. Retrieval
  3. Fertilisation , not started
  4. Transfer , not started
  1. Stimulation , completed
  2. Retrieval
  3. Fertilisation , not started
  4. Transfer , not started

Guidelines

  • Use a stepper to show where a process of a few known steps stands: a treatment, an onboarding, a form in parts.
  • It shows the way, it does not move along it: the page sets current, and its own buttons go back and forth.
  • Keep to the steps that matter, about three to six, each named in a word or two. A longer history is a timeline.
  • Use outline on a plain page, where the edge holds the steps ahead together. Use filled inside a card or a panel that already draws edges of its own.
  • Use horizontal at the head of a page, and vertical in a side column or where the steps carry a description.
  • Set current past the last step when the process is over: every step then shows done.

Accessibility

  • It renders an ordered list, <ol>, so a screen reader says how many steps there are and which one it is on.
  • The current step carries aria-current="step".
  • The others say their state after the label, as "Retrieval, completed" or "Transfer, not started". Change the words with doneLabel and upcomingLabel.
  • The numbers, ticks and lines are hidden from assistive technology: the list says the same.
  • Give the list an aria-label, as "Treatment progress", when the page does not name it.

API reference

PropTypeDefault
stepsStepperStep[]

The steps, in order, each a label and an optional description. Required.

—
currentnumber

The step in progress, from 0. The ones before are done; past the last one, all are.

0
variant'outline' | 'filled'

How the steps ahead are drawn: on the edge of a control, or on a soft grey with no edge.

'outline'
orientation'horizontal' | 'vertical'

A row with lines between the steps, or a column.

'horizontal'
doneLabelstring

Read after the label of a step done.

'completed'
upcomingLabelstring

Read after the label of a step ahead.

'not started'

Plus every attribute of an <ol>.