Stepper
The steps of a process and where it stands: done, current and ahead, in a row or a column.
- Stimulation , completed
- Retrieval , completed
- Fertilisation
- Transfer , not started
Installation
pnpm dlx @human-kit/design add steppernpx @human-kit/design add stepperyarn dlx @human-kit/design add stepperbunx @human-kit/design add stepperThe 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.
- Stimulation , completed
- Retrieval
- Fertilisation , not started
- Transfer , not started
- Stimulation , completed
- Retrieval
- Fertilisation , not started
- 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
outlineon a plain page, where the edge holds the steps ahead together. Usefilledinside a card or a panel that already draws edges of its own. - Use
horizontalat the head of a page, andverticalin a side column or where the steps carry adescription. - Set
currentpast 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
doneLabelandupcomingLabel. - 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
| Prop | Type | Default |
|---|---|---|
steps | StepperStep[] The steps, in order, each a | — |
current | number 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' |
doneLabel | string Read after the label of a step done. | 'completed' |
upcomingLabel | string Read after the label of a step ahead. | 'not started' |
Plus every attribute of an <ol>.