Skip to Content
BBRICKSv0.7.4
PR PortalForms and dialogs

Stepper

The challenge builder's stepper (.stepper): one bar per step, done and current bars raspberry, labels "1. Basics". Every step is a button (go back or jump ahead, as the mock allows); the current one has aria-current="step".

import { Stepper } from '@ergasti/bricks';

Examples

What changes

Old value, new value, a worked example and a note about when it applies; changed turns the arrow on.

Code
import { ChangePreview } from '@ergasti/bricks';

function Preview() {
  return (
    <div style={{ maxWidth: 480 }}>
      <ChangePreview from="8% of sale" to="10% of sale" changed example={<>On an EGP 1,000 order, the creator earns <b>EGP 100</b>.</>} note="Applies to orders placed after you save. Orders already placed keep the old rate." />
    </div>
  );
}

Stepper

Numbered steps for a builder; finished steps are buttons when you pass onStep.

Code
import { useState } from 'react';
import { Stepper } from '@ergasti/bricks';

function Steps() {
  const [step, setStep] = useState(1);
  return <Stepper steps={['Basics', 'Type & goal', 'Who can join', 'Reward']} current={step} onStep={setStep} />;
}

Nothing changed yet, and an invalid value

changed={false} greys the arrow while the new value equals the old; error replaces the worked example with why the new value cannot be saved.

Code
import { ChangePreview } from '@ergasti/bricks';

function States() {
  return (
    <div style={{ display: 'grid', gap: 16, maxWidth: 480 }}>
      <ChangePreview from="8% of sale" to="8% of sale" changed={false} />
      <ChangePreview from="8% of sale" to="120% of sale" changed error="A commission cannot be more than 100% of the sale." />
    </div>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prEditing, or with the component's own prop where it has one. A {name} is a value the component fills in.

prEditing
KeyEnglishArabic
noneNo changes yet.مفيش تغييرات لسه.
wasWasكان
nowNowدلوقتي
stepsStepsالخطوات
stepStep {i} of {n}خطوة {i} من {n}
donedoneخلصت

Design guidance

How the BRICKS design system uses Stepper. Written in docs/content/components/Stepper.md; the props above are read from the code, which wins where the two disagree.

The challenge builder's step bar: one bar per step with a numbered label, done and current steps raspberry; use it above a multi-step PR form.

Stepper is the mock's .stepper. Each step is a thin bar with "1. Basics" under it. With onStep every step is a button, so PR can go back or jump ahead as the mock allows; without it the steps are text. The current step has aria-current="step", done steps say "(done)" to screen readers, and "Step 2 of 4" is announced politely on change.

Anatomy

  1. Nav: <nav aria-label="Steps" class="kit-pr-stepper">.
  2. List: <ol>, flex, 6px gap, one equal <li> per step.
  3. Step: a <button> (with onStep) or <span>: a 5px bar (--track, raspberry when done or current), then "1. Basics" (13px / 600, --ink-3; current in --ink).
  4. Live text: hidden "Step 2 of 4".

Variants

PropValueEffect
onStepgivenSteps are buttons
omittedSteps are text (not clickable)

States

StateLook
Done (i < current)Raspberry bar, "(done)" for AT
CurrentRaspberry bar, ink label, aria-current="step"
UpcomingTrack bar, muted label
Focus-visiblefocus ring on the button
Phone (≤600px)only the current step's label shows; bars stay
Touch (≤1024px)each step is a 44px target

Usage

import { useState } from 'react';
import { Stepper } from '@ergasti/bricks';

export function Steps() {
  const [step, setStep] = useState(1);
  return <Stepper steps={['Basics', 'Type & goal', 'Who can join', 'Reward']} current={step} onStep={setStep} />;
}
// Challenge builder: stepper, the step's form, and the summary beside it
<Stepper steps={['Basics', 'Type & goal', 'Who can join', 'Reward']} current={step} onStep={setStep} />
<div style={{ display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) 360px', gap: 24 }}>
  <Card>{step === 1 && <ChoiceGroup label="Challenge type" value={type} onChange={setType} options={typeOptions} />}</Card>
  <ChallengeSummary {...summary} layout="flat" />
</div>

Where it appears

  • PR Portal › Affiliate programs › Challenges › challenge builder (steps 1-4).

Guidelines

Do

  • Keep labels to one or two words.
  • Let PR jump back freely; validate before moving forward.

Don't

  • Don't use it for more than five steps.
  • Don't use it as page tabs; use PillTabs.

RTL and Arabic

Bars run right to left; the step number stays dir="ltr" ("1.").

Tokens

--track, --rasp, --ink, --ink-3, --focus-ring, --radius-xs, --min-touch-target.

Accessibility

A labelled nav with an ordered list; current step aria-current="step"; done steps announced; the position is read politely on change; 44px targets on touch tiers (≤1024px).

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-live, aria-hidden, aria-current, aria-label.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: PrIcon · useLanguage · ChangePreview · BulkAction · DecisionsCard

Source

src/pr/Editing.tsx (line 58) on GitHub.

On this page