Stepper
Definition
A stepper shows a numbered sequence of steps in a linear process, and which of them are done, current and upcoming. Use it for a process the user moves through in order, where tabs would wrongly suggest the sections can be visited in any order.
The stepper is a set of CSS classes, not a template. The page writes the list, so a step can hold any markup and can be rendered by Django or by Alpine.
- Shows done, current and upcoming steps.
- Lays out horizontally or vertically.
- Display only: make a step a link or a button by putting one inside it.
Classes
| Class | Goes on | Effect |
|---|---|---|
stepper |
The <ol> |
Lays the steps out in a row that wraps. |
stepper-vertical |
The <ol> |
Stacks the steps in a column. |
stepper-connected |
The <ol> |
Draws a line from each step to the next. A row no longer wraps. |
stepper-step |
Each <li> |
One step: its mark, then its label. An upcoming step needs no other class. |
is-done |
A stepper-step |
The step is finished. |
is-current |
A stepper-step |
The step is the one in progress. |
stepper-mark |
A <span> in the step |
The circle that holds the step number or an icon. |
The colours come from the theme (--bs-success, --primary, --bs-border-color, --bs-secondary-color), so the stepper follows the light and dark themes.
Example
<ol class="stepper">
<li class="stepper-step is-done">
<span class="stepper-mark"><i class="bi bi-check-lg"></i></span>
<span>Transactions</span>
</li>
<li class="stepper-step is-current">
<span class="stepper-mark">2</span>
<span>Receipts</span>
</li>
<li class="stepper-step">
<span class="stepper-mark">3</span>
<span>Books balanced</span>
</li>
</ol>
<ol class="stepper stepper-vertical">
{% for step in steps %}
<li class="stepper-step {% if step.is_done %}is-done{% elif step.is_current %}is-current{% endif %}">
<span class="stepper-mark">
{% if step.is_done %}<i class="bi bi-check-lg"></i>{% else %}{{ forloop.counter }}{% endif %}
</span>
<span>{{ step.name }}</span>
</li>
{% endfor %}
</ol>
<ol class="stepper stepper-connected">
<li class="stepper-step is-done">
<span class="stepper-mark"><i class="bi bi-check-lg"></i></span>
</li>
<li class="stepper-step is-current">
<span class="stepper-mark">2</span>
</li>
<li class="stepper-step">
<span class="stepper-mark">3</span>
</li>
</ol>