Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 07 Navigation

Stepper

A flow split into steps, such as checkout. Each step holds its own content, and the stepper shows the current one with Back and Next under it. The step names are buttons, so people can go back. Done steps have a tick and are read as Done, the current one is announced as the current step, and focus moves to the new step's content after each change.

Use it in Angular
import { StepComponent, StepperComponent } from '@okaapi-ui/angular';

Try it

Change the options and the stepper follows. With linear, a step must be marked as filled in before Next or the later steps work.

4 steps

Options

Turn linear on, then try to reach a later step before filling in the current one.

Angular
<ui-stepper label="Checkout" [linear]="linear" [(current)]="step">
  <ui-step label="Step 1" [completed]="done1">…</ui-step>
  <ui-step label="Step 2" [completed]="done2">…</ui-step>
</ui-stepper>

Try the screen

Set the screen width: the stepper puts each name under its circle once its own box is under 30rem.

Screen 24rem (384px)

At any screen width

The same stepper in a box as wide as the slider says. It reads its own box, not the window.

Cairo.

Angular
<ui-stepper label="Checkout" [linear]="linear" [(current)]="step">
  <ui-step label="Step 1" [completed]="done1">…</ui-step>
  <ui-step label="Step 2" [completed]="done2">…</ui-step>
</ui-stepper>

Checkout, in order

A whole flow. The address and card steps are completed once their fields are valid; press Next with them empty to see the errors. Finish places the order.

2 items, EGP 1,250.

Angular
<ui-stepper label="Checkout" linear
  [(current)]="step"
  (blocked)="showErrors($event)"
  (finish)="placeOrder()">
  <ui-step label="Cart">…</ui-step>
  <ui-step label="Address" [completed]="address.valid">
    <ui-text-field label="Full name" formControlName="name"
      [error]="name.invalid && name.touched ? 'Enter your full name' : undefined" />
    <ui-text-field label="Email" type="email" formControlName="email" />
  </ui-step>
  <ui-step label="Payment" [completed]="card.valid">
    <ui-text-field label="Card number" [formControl]="card" />
  </ui-step>
  <ui-step label="Review">…</ui-step>
</ui-stepper>

In Arabic

Without linear, every step can be chosen. Translate the button labels and Done.

الدفع عند الاستلام.

Angular
<ui-stepper label="إتمام الطلب" doneLabel="تم"
  backLabel="السابق" nextLabel="التالي" finishLabel="إنهاء"
  [number]="arabicDigits" [current]="2">
  <ui-step label="السلة">…</ui-step>
  <ui-step label="العنوان">…</ui-step>
  <ui-step label="الدفع">…</ui-step>
  <ui-step label="المراجعة">…</ui-step>
</ui-stepper>

arabicDigits = (n: number) => n.toLocaleString('ar-EG');

When to use something else

If you needUse
Views the reader can open in any orderTabs
Pages of a listPagination
What happened to a request, in time orderTimeline

Inputs

NameTypeDefaultWhat it does
labelstring — Required. Names the list of steps: "Checkout".
linearbooleanfalseEach step waits for the ones before it to be completed, and Next waits for the current one.
doneLabelstring'Done' from labelsRead before each done step. Translate it.
backLabel | nextLabel | finishLabelstring'Back' | 'Next' | 'Finish' from labelsThe button labels. Translate them.
number(n: number) => stringStringThe marker's number, for Arabic digits.
currentnumber0Index of the current step; two-way with [(current)].
(blocked)number — Linear only: Next or Finish was pressed on this step while it is not completed. Show its errors.
(finish)void — Finish was pressed on the last step.
ui-step labelstring — Required. The step's name; its content goes inside.
ui-step completedbooleantrueWhether the step is filled in, such as its form being valid. A step before the current one shows a tick only when it is.

Keyboard and screen readers

KeysWhat they do
Tab Reach the step names, Back and Next.
  • Done steps are read as Done and the current one as the current step.
  • Focus moves to the new step’s content after each change.