@k8ordo/ui

Stepper

The steps of a process in order, marking the completed ones and the current one. Use it to show progress through a multi-step form.

Import

ts
import { Stepper } from '@k8ordo/ui';

Usage

value is the index of the current step, counted from 0. Completed steps show a check and are read as completed. The current step carries aria-current="step".

  1. PlanPick what fitscompleted
  2. PaymentCard or invoice
  3. ReviewCheck and send
tsx
const steps = [
  { label: 'Plan', description: 'Pick what fits' },
  { label: 'Payment', description: 'Card or invoice' },
  { label: 'Review', description: 'Check and send' },
];

<Stepper aria-label="Sign-up" steps={steps} value={1} />

Going back to a completed step

With interactive, completed steps become buttons. Pressing one hands its index to onChange. Steps ahead cannot be jumped to.

  1. ReviewCheck and send
tsx
const [step, setStep] = useState(2);

<Stepper
  aria-label="Sign-up"
  interactive
  onChange={setStep}
  steps={steps}
  value={step}
/>

Vertical

  1. PlanPick what fitscompleted
  2. PaymentCard or invoice
  3. ReviewCheck and send
tsx
<Stepper
  aria-label="Sign-up"
  orientation="vertical"
  steps={steps}
  value={1}
/>

Props

steps
Type: readonly StepperStep[]
Default: -
defaultValue?
Type: number
Default: -
interactive?
Type: boolean
Default: false
onChange?
Type: (value: number) => void
Default: -
orientation?
Type: 'horizontal'|'vertical'
Default: 'horizontal'
ref?
Type: Ref<HTMLOListElement>
Default: -
value?
Type: number
Default: -
PropTypeDefault
stepsreadonly StepperStep[]-
defaultValue?number-
interactive?booleanfalse
onChange?(value: number) => void-
orientation?'horizontal'|'vertical''horizontal'
ref?Ref<HTMLOListElement>-
value?number-

Inherited attributes (except the ones set internally): OlHTMLAttributes<HTMLOListElement>

The wording this component draws (labels, placeholders, and so on) comes from the message dictionary unless a prop sets it. To replace it, see: i18n

k8ordo

React libraries that use Baseline features without holding back.