Stepper

The steps of a longer flow: a tick for the ones done, a ring around the one you are on and a quiet number for the rest. The line between two steps fills as you move on.

  1. Services Completed
  2. Budget Completed
  3. 3 Timeline Current step
  4. 4 Details Up next

When should we start?

Pick a rough date. We confirm the exact week once the brief is agreed.

Options

Screen
Colour

Code

import "./stepper.css";

const words = { done: "Completed", active: "Current step", next: "Up next" };

/* The steps of a longer flow. steps is a list of names, and current is the
   number of the step the person is on, counting from 0.

   <Stepper steps={["Services", "Budget", "Timeline", "Details"]} current={2} /> */
export function Stepper({ steps, current, label = "Progress" }) {
  return (
    <ol className="dh-stepper" aria-label={label}>
      {steps.map((step, index) => {
        const state = index < current ? "done" : index === current ? "active" : "next";
        return (
          <li
            key={step}
            data-state={state === "next" ? undefined : state}
            aria-current={state === "active" ? "step" : undefined}
          >
            <i>
              {state === "done" ? (
                <svg viewBox="0 0 12 12" aria-hidden="true">
                  <path d="M2.500 6.300 5 8.700l4.500-5.200" />
                </svg>
              ) : (
                index + 1
              )}
            </i>
            <span>
              {step} <small>{words[state]}</small>
            </span>
          </li>
        );
      })}
    </ol>
  );
}

export function Example() {
  return (
    <section className="dh-stepper-card">
      <Stepper steps={["Services", "Budget", "Timeline", "Details"]} current={2} />
      <div>
        <h3>When should we start?</h3>
        <p>Pick a rough date. We confirm the exact week once the brief is agreed.</p>
      </div>
      <footer>
        <button type="button">Back</button>
        <button type="button">Continue</button>
      </footer>
    </section>
  );
}
  1. Services Completed
  2. Budget Completed
  3. 3 Timeline Current step
  4. 4 Details Up next

When should we start?

Pick a rough date. We confirm the exact week once the brief is agreed.