React Stepper
An animated React stepper for multi-step forms and checkouts that collapses to “Step 2 of 4” on phones.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/stepper.jsonNext: Account
StepperdefaultStepperLabels
Checkout
Click a completed step to go back to it. Toggle the error to see a step flag itself; screen readers hear each step's state.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Stepper } from "@/components/sheenui/stepper/stepper";
import { Switch } from "@/components/sheenui/switch/switch";
// Package build (after the first npm release, or a packed tarball): import { Button, Stepper, Switch } from "@sheenui/theme";
// This example also uses button, switch: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/switch.json
export function Example() {
const [current, setCurrent] = useState(1);
const [failed, setFailed] = useState(false);
return (
<>
<Switch label="Payment fails" checked={failed} onCheckedChange={setFailed} />
<Stepper
current={current}
onStepClick={setCurrent} // completed steps become buttons
labels={{ nav: "Checkout progress" }}
steps={[
{ title: "Cart", description: "3 items" },
{ title: "Shipping", description: "Address and speed" },
{ title: "Payment", description: "Card or wallet", status: failed ? "error" : undefined },
{ title: "Review", description: "Confirm and pay" },
]}
/>
<Button variant="ghost" onClick={() => setCurrent((c) => c - 1)}>Back</Button>
<Button onClick={() => setCurrent((c) => c + 1)}>Continue</Button>
</>
);
}Files to copy
5 folders · 3 files · 4 packages
- From
theme/src/ components/stepper/components/status-icons/hooks/use-latest.tslib/{cn.ts, form.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/stepper.jsonRegistry item: stepper. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/button/components/spinner/components/switch/hooks/{use-direction.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, tokens.ts}lib/{field-control-shell.tsx, motion-props.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/switch.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Vertical, with content
The current step reveals its own content. Optional steps say so.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Stepper } from "@/components/sheenui/stepper/stepper";
// Package build (after the first npm release, or a packed tarball): import { Button, Stepper } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
export function Example() {
const [current, setCurrent] = useState(0);
// "Continue" inside a step's content unmounts with it: focus moves to the next step for you.
return (
<Stepper
orientation="vertical"
current={current}
onStepClick={setCurrent}
labels={{ nav: "Workspace setup" }}
steps={[
{ title: "Create a workspace", description: "Name it and pick a region", content: <p>Workspace name and region go here.</p> },
{ title: "Invite your team", optional: true, content: <p>Email addresses go here.</p> },
{ title: "Connect a repository", description: "Import repositories", content: <Button variant="glass">Connect a repository</Button> },
{ title: "Ship it", description: "Your first deploy" },
]}
/>
);
}Labels beside, compact, translated
labelPlacement="end" puts titles next to the dots. The compact view is what phones get automatically. Every string, punctuation included, comes from labels.
import { Stepper, type StepperStep } from "@/components/sheenui/stepper/stepper";
// Package build (after the first npm release, or a packed tarball): import { Stepper, type StepperStep } from "@sheenui/theme";
const steps: StepperStep[] = [
{ title: "Cart", description: "3 items" },
{ title: "Shipping" },
{ title: "Payment" },
{ title: "Review" },
];
export function Example() {
return (
<>
{/* Labels beside the dots, small size */}
<Stepper labelPlacement="end" size="sm" current={1} steps={steps.map(({ title }) => ({ title }))} />
{/* Phones: "auto" (the default) collapses to "Step 2 of 4" when steps get narrower than minStepWidth; "always" forces the compact view. */}
<Stepper collapse="always" current={1} steps={steps} />
{/* Every string is a label, punctuation included (French shown): */}
<div lang="fr">
<Stepper
collapse="always"
current={1}
steps={[{ title: "Panier", description: "3 articles" }, { title: "Livraison" }, { title: "Paiement" }]}
labels={{
nav: "Progression",
stepOf: (step, total) => `Étape ${step} sur ${total}`,
complete: "terminée",
current: "étape en cours",
upcoming: "à venir",
error: "à corriger",
status: (words) => ` : ${words.join(", ")}`,
next: (title) => <>Suivante : <strong>{title}</strong></>,
}}
/>
</div>
</>
);
}Stepper
StepperLabels keys and English defaults (10)
Keyboard
Accessibility
- An ordered list (<ol>) in a <nav>; the current step has aria-current="step" and every state (complete, current, upcoming, error) is also spoken.
- When current changes, keyboard focus stays in the stepper (it moves to the next step if its button disappeared).
- The compact "Step 2 of 4" view keeps the same information; every string is translatable through labels.
All exports on this page
Stepper— Stepper: progress through a multi-step flow (checkout, onboarding, setup wizards).defaultStepperLabels— Default English strings of StepperLabels; spread it and override single keys to reword.
When to use Stepper
- Use it as the progress steps of a multi-step form, such as a checkout with Cart, Shipping, Payment and Review, where completed steps can be revisited and a failed payment step can flag itself with an error state.
- Use orientation="vertical" with per-step content for an onboarding or setup wizard, where the current step reveals its own form and optional steps are labeled as such.
- Use it for a long application form on phones, where the automatic compact view shows Step 2 of 4 with a segmented bar instead of cramped titles.
- Skip it when the user can move between views freely with no order; Tabs is the right pattern for parallel views, and Breadcrumb shows where a page sits in the site hierarchy.
- Pair it with Button for Back and Next, Field and Input for each step's form, and Progress when you also want a continuous completion value.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .