Skip to content
TopClass UI

Stepper

Where a reader is in a task of a few steps. A done step carries a tick, not just a colour, so it survives a greyscale screenshot.

server - 0 KB

Stepper

server - 0 KB

Where a reader is in a task of a few steps. A done step carries a tick, not just a colour, so it survives a greyscale screenshot.

Install
  1. AccountCompleted
  2. Profile
  3. TeamNot started
  4. DoneNot started

Try it

size

The code

stepper.tsx
import { Stepper, type StepperDesignProps } from 'topclassui/stepper'

<Stepper items={STEPS} value="profile" aria-label="Sign-up" />

Stepper renders on the server: pass value, the id of the current step. It shows progress; it does not navigate.

Every state

4 states
  1. Cart
  2. AddressNot started
  3. PaymentNot started
  1. CartCompleted
  2. Address
  3. PaymentNot started
  1. CartCompleted
  2. AddressNeeds attention
  3. PaymentNot started
  1. CartCompleted
  2. AddressCompleted
  3. PaymentCompleted

Import from the package

topclassui/stepper
import { Stepper } from 'topclassui/stepper'

Install once:npm i topclassui@beta zod

Examples

  • A step is { id, title, status? }, with status one of done, current, todo and error.
  • Steps before value are done, steps after it todo. With no value the first step is current; a value no step has leaves every step todo.
  • A step's own status wins over value: error draws an x and is read as "Needs attention".
  • size sets the circles, from 24 to 48 px, and the titles. With custom the circle reads --tc-stepper-mark, 32 px unless you set it.
  • A long title wraps inside its column and is never cut. Steps that do not fit across wrap onto another row, so the page never scrolls sideways.
basic
  1. AccountCompleted
  2. Profile
  3. TeamNot started
  4. DoneNot started
statuses
  1. UploadCompleted
  2. CheckNeeds attention
  3. Publish
  4. ShareNot started
sizes
  1. CartCompleted
  2. Address
  3. PaymentNot started
  1. CartCompleted
  2. Address
  3. PaymentNot started
  1. CartCompleted
  2. Address
  3. PaymentNot started
  1. CartCompleted
  2. Address
  3. PaymentNot started
  1. CartCompleted
  2. Address
  3. PaymentNot started
custom-size
  1. UploadCompleted
  2. CheckNeeds attention
  3. Publish
  4. ShareNot started
  1. UploadCompleted
  2. CheckNeeds attention
  3. Publish
  4. ShareNot started
long-content
  1. Confirm the billing address on the orderCompleted
  2. Choose a delivery slot for the big itemsCompleted
  3. Add the gift note and the wrapping paper
  4. Review every line of the order, then payNot started
  5. Pay with a saved card or a bank transferNot started
  6. Download the receipt and tracking numberNot started
arabic-digits
  1. السلةمكتمل
  2. العنوانمكتمل
  3. الدفع
  4. التأكيدلم يبدأ
  1. السلةمكتمل
  2. العنوانمكتمل
  3. الدفع
  4. التأكيدلم يبدأ
In Arabic, right to left
  1. الحسابمكتمل
  2. الملف الشخصي
  3. الفريقلم يبدأ
  4. تملم يبدأ

Props

The props of Stepper
PropTypeDefaultLimitsDescription
items*readonly StepperItem[]--The steps, first to last. A connector runs from each circle to the next.
labelsLabels--The built-in strings, which say each step's status. Defaults to English; spread getLabels(locale) for another.
localestring--The locale the step numbers are written in: ar-u-nu-arab gives Arabic-Indic digits. Defaults to en.
sizexs | sm | md | lg | xl | custom"md"-The size of the circles (24 to 48 px) and of the titles; custom emits none.
valuestring--The id of the current step: those before it are done, those after it todo. Defaults to the first step's id.

Keyboard and accessibility

Nothing to operate: it is not interactive on its own.

  • An ordered list, which gives "2 of 4", with role="list" written so Safari with VoiceOver keeps it.
  • The current step carries aria-current="step"; every other step has a hidden word for its status, from labels.
  • The circles are hidden from screen readers, and nothing takes focus.

Right to left

The steps run from the right by themselves. locale decides the digits: ar-u-nu-arab writes the numbers in Arabic-Indic digits.

Server and client

Renders on the server and ships no JavaScript.

Files: index.tsx.

On the chip: server - 0 KB.