Step walker

Pro

A guided walk (Candor's StepWalker): the stages across the top, the current one as a focus card below. Finished stages can be revisited; later ones can't be skipped to.

Markdown

Preview

Install

With the Candor CLI

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/step-walker

Brings in: locale, utils · npm: lucide-react@^1.67.0

Usage

TSX · The example above
"use client"

import * as React from "react"
import { StepWalker } from "@/components/step-walker"
import { Button } from "@/components/ui/button"

const stages = ["Choose a repository", "Consent", "First read"]

const body = [
  "Pick the repository Keel should learn first. You can add more later.",
  "See exactly what Keel reads and where it goes, then allow it.",
  "Keel reads acme-api: tables, migrations and flags. You can ask questions while it reads.",
]

export default function Example() {
  const [stage, setStage] = React.useState(0)
  const last = stage === stages.length - 1
  return (
    <StepWalker className="w-full max-w-xl" stages={stages} current={stage} onGoTo={setStage}>
      <div className="rounded-xl border bg-card p-5">
        <h3 className="text-base font-semibold">{stages[stage]}</h3>
        <p className="mt-1 text-sm text-muted-foreground">{body[stage]}</p>
        <div className="mt-4 flex justify-end">
          <Button size="sm" variant={last ? "ghost" : "default"} onClick={() => setStage(last ? 0 : stage + 1)}>
            {last ? "Start over" : "Continue"}
          </Button>
        </div>
      </div>
    </StepWalker>
  )
}

<StepWalker>

PropTypeDefaultDescription
stagesrequiredstring[]—Stage names, in order.
currentrequirednumber—Index of the current stage, from 0; earlier ones show as done.
onGoTo((index: number) => void) | undefined—Lets finished stages be revisited; called with the stage's index.
childrenrequiredReact.ReactNode—What goes inside.
classNamestring | undefined—Extra classes for the outer element.

Strings

The fixed words, in English by default. Change any of them under stepWalker in <LocaleProvider strings={{ … }}>; the table is exported as stepWalkerStrings.

KeyEnglish
stepsSteps