ebnsina

Stepper

Navigation

About

A multi-step progress indicator for forms and flows that marks finished, current and upcoming steps, lets users go back to a completed step, and can show a step with an error in place of its description.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Stepper to your project and fits it to your theme.

Code

How Stepper is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import Stepper from "@/components/ui/stepper";

const steps = [
  { label: "Reader", description: "Who is borrowing" },
  { label: "Manuscript", description: "What to copy" },
  { label: "Collection", description: "When and where" },
  { label: "Review", description: "Check and send" },
];

export default function StepperFlowDemo() {
  const [current, setCurrent] = React.useState(0);
  const headingRef = React.useRef<HTMLHeadingElement>(null);

  function go(to: number) {
    setCurrent(to);
    requestAnimationFrame(() => headingRef.current?.focus());
  }

  return (
    <div className="grid w-full max-w-xl gap-6">
      <Stepper
        steps={steps}
        current={current}
        onstep={go}
        label="Borrowing request"
      />

      <div className="grid gap-3">
        <h3
          ref={headingRef}
          tabIndex={-1}
          className="m-0 text-sm font-semibold outline-none"
        >
          {steps[current].label}
        </h3>
        {current === 0 && (
          <label className="grid gap-1 text-sm text-muted-foreground">
            Name
            <input
              className="rounded-md border bg-transparent px-3 py-2 text-foreground"
              defaultValue="Maryam al-Ijliya"
              readOnly
            />
          </label>
        )}
        {current === 1 && (
          <label className="grid gap-1 text-sm text-muted-foreground">
            Manuscript
            <input
              className="rounded-md border bg-transparent px-3 py-2 text-foreground"
              defaultValue="Book of Optics"
              readOnly
            />
          </label>
        )}
        {current === 2 && (
          <label className="grid gap-1 text-sm text-muted-foreground">
            Reading room
            <input
              className="rounded-md border bg-transparent px-3 py-2 text-foreground"
              defaultValue="Bayt al-\u1e24ikma, Baghdad"
              readOnly
            />
          </label>
        )}
        {current === 3 && (
          <p className="m-0 text-sm text-muted-foreground">
            Maryam al-Ijliya \u00b7 Book of Optics \u00b7 Bayt al-\u1e24ikma,
            Baghdad
          </p>
        )}
      </div>

      <div className="flex justify-end gap-2">
        <button
          type="button"
          className="rounded-md px-3 py-2 text-sm font-medium disabled:opacity-40"
          disabled={current === 0}
          onClick={() => go(current - 1)}
        >
          Back
        </button>
        {current < steps.length - 1 ? (
          <button
            type="button"
            className="rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground"
            onClick={() => go(current + 1)}
          >
            Continue
          </button>
        ) : (
          <button
            type="button"
            className="rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground"
            onClick={() => go(0)}
          >
            Send request
          </button>
        )}
      </div>
    </div>
  );
}

Dependencies

More by ebnsina

View all
  • Countdown Timer

    Countdown Timer

    35
  • Video Player

    Video Player

    26
  • Alarm Clock

    Alarm Clock

    24
  • Hourglass Timer

    Hourglass Timer

    19
  • Voice Note

    Voice Note

    19
  • Sortable List

    Sortable List

    17
  • Sign In Auth Card

    Sign In Auth Card

    13
  • Split Button

    Split Button

    13

More in Navigation

View all
  • Footer with Big Wordmark

    Footer with Big Wordmark

    67
  • Liquid Glass Expandable Sidebar

    Liquid Glass Expandable Sidebar

    179
  • Sidebar

    Sidebar

    406
  • Button Breadcrumb

    Button Breadcrumb

    33
  • Menu

    Menu

    26
  • Breadcrumb

    Breadcrumb

    7
  • Pagination with Ellipsis

    Pagination with Ellipsis

    25
  • Pagination

    Pagination

    112