[!NOTE] Compound component — an opinionated composition of Helix primitives. Composes:
Progress. Sits in aCardorDialog; the footer is the wizard footer fromhelix-form-patterns.
Import
import { Stepper, StepperCount } from "@timelycare/helix-ui"
Usage
const [step, setStep] = useState(1)
const [visitType, setVisitType] = useState("")
const missing = step === 1 && !visitType ? "Pick a visit type to continue" : null
<Card>
<CardHeader>
<CardTitle as="h2">Schedule a visit</CardTitle>
<CardAction><StepperCount currentStep={step} totalSteps={7} /></CardAction>
<CardDescription>Tell us what the visit is for.</CardDescription>
</CardHeader>
<CardContent className="grid gap-5">
<Stepper variant="linear-progress" currentStep={step} totalSteps={7} />
<Field>
<FieldLabel htmlFor="visit-type">Visit type</FieldLabel>
<Input id="visit-type" value={visitType} onChange={(e) => setVisitType(e.target.value)} />
</Field>
</CardContent>
<CardFooter className="gap-2">
{step > 1 && <Button variant="outline" onClick={() => setStep(step - 1)}>Back</Button>}
<div className="ml-auto flex items-center gap-3">
{missing && <p id="visit-missing" className="text-muted-foreground text-sm">{missing}</p>}
<Button disabled={!!missing} aria-describedby={missing ? "visit-missing" : undefined} onClick={() => setStep(step + 1)}>Next</Button>
</div>
</CardFooter>
</Card>
Choosing a variant
| Variant | Use when | What it draws |
|---|---|---|
vertical | Long full-page flows (5+ steps) whose step names carry meaning | A rail beside the form: a marker per step, its name, and an optional one-line description |
horizontal | Medium flows (3–5 steps), often in a dialog, whose step names matter | A row above the form: markers joined by lines, each name centred underneath |
linear-progress | Short flows (5 steps or fewer) where the step names add nothing | The Progress bar, filled to step N of M |
linear-progress shows the value only: the bar, with no "20% complete" caption next to it. The bar fills N of M, so step 1 of 7 is a seventh full and the last step is full while its Submit button is still ahead.
The header row
"Step N of M" belongs at the right end of the header row, whichever variant you use. Put StepperCount in CardAction, between CardTitle and CardDescription; CardHeader already lays the action out on the right. Do not add a small uppercase label above the title ("STEP 1 OF 7 · VISIT DETAILS"). The title says what this step is.
A dialog has no action slot, and its close button sits in the top-right corner. End the title row with the count instead, and keep it clear of the close button:
<DialogHeader>
<div className="flex items-baseline justify-between gap-4 pr-8">
<DialogTitle>Create campaign</DialogTitle>
<StepperCount currentStep={step} totalSteps={4} />
</div>
<DialogDescription>Follow the steps to create and launch your campaign.</DialogDescription>
</DialogHeader>
<Stepper variant="horizontal" steps={steps} currentStep={step} onStepSelect={setStep} />
Steps and their states
currentStep counts from 1, and you control it. Steps before it show as done (a check), the current one has a bold ring and a bold name, and later ones have a thin grey ring. A step's state overrides that: "complete" for a later step someone already finished before going back, "error" for a step that needs attention (a red "!").
Keep step names to two or three words in sentence case: "Visit details", "Review & launch".
Going back
Pass onStepSelect and every earlier step becomes a button that takes someone back. A later step marked "complete" or "error" becomes one only when every step between the current one and it is complete, so nobody can skip a step they have not finished. Upcoming steps never do: moving forward is the Next button's job, and Next waits until the step is valid. Clicking ahead still leaves the current step unchecked: in onStepSelect, check the current step first when the target is after it. Without onStepSelect, the indicator is not clickable at all.
Narrow screens
A horizontal Stepper narrower than 448px keeps its markers and lines, moves the step names to screen readers only, and shows the current step's name once under the row. That covers phones and narrow dialogs with no code from you.
A vertical rail has no room beside the form on a phone. Render the rail from md up and a horizontal Stepper below it:
<div className="grid gap-6 md:grid-cols-3">
<Stepper variant="vertical" steps={steps} currentStep={step} className="hidden md:block" />
<Stepper variant="horizontal" steps={steps} currentStep={step} className="md:hidden" />
<Card className="md:col-span-2">…</Card>
</div>
What Stepper does not do
Stepper draws the indicator only. The footer (Back on the left from step 2, Next on the right, disabled until the step is valid, with a muted line saying what is missing) is the wizard footer in helix-form-patterns, built from Buttons. Moving focus to the new step's heading or first field after a step change is yours too.