Stepper
Numbered steps that turn into checks.
Installation
Run the CLI
Run
pnpm dlx asta-ui@latest initonce, then this. The file lands incomponents/astabyte/and the colour tokens go into your CSS.$ pnpm dlx asta-ui@latest add stepperOr install the package
Don’t want the file? Import from
asta-ui/stepperand update withpnpm update asta-ui. Add the stylesheet once. More.$ pnpm add asta-uiimport { Stepper } from "asta-ui/stepper";Or copy it by hand
Copy this file. Keep the paths, or fix the
@/imports. Then add the tokens fromglobals.css."use client"; import { useId, useState, type ReactNode } from "react"; const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" "); export interface StepItem { title: string; description?: string; content?: ReactNode; } export interface StepperControls { step: number; next: () => void; back: () => void; goTo: (step: number) => void; isFirst: boolean; isLast: boolean; /** True once `step` has moved past the last step. */ isComplete: boolean; } export interface StepperProps { steps: StepItem[]; /** Current step, 0-based. `steps.length` means every step is done. */ step?: number; defaultStep?: number; onStepChange?: (step: number) => void; /** Lets people click a finished step to go back to it. */ clickable?: boolean; /** Shown in place of step content once every step is done. */ complete?: ReactNode; /** Rendered under the content, e.g. Back / Next buttons. A function gets the controls. */ children?: ReactNode | ((controls: StepperControls) => ReactNode); className?: string; } const KEYFRAMES = `@keyframes kit-step-next { from { opacity: 0; transform: translateX(32px) } } @keyframes kit-step-back { from { opacity: 0; transform: translateX(-32px) } }`; function Mark({ index, state }: { index: number; state: "done" | "current" | "todo" }) { const done = state === "done"; return ( <span className={cx( "relative flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-[13px] font-medium tabular-nums transition-[background-color,box-shadow,color] duration-300", done && "bg-brand text-on-brand", state === "current" && "bg-paper text-brand shadow-[inset_0_0_0_1.5px_var(--color-brand),0_0_0_4px_color-mix(in_srgb,var(--color-brand)_14%,transparent)]", state === "todo" && "bg-paper text-mute shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_16%,transparent)]", )} > <span className={cx("transition-[opacity,transform] duration-300 ease-[cubic-bezier(.16,1,.3,1)] motion-reduce:transition-none", done ? "scale-50 opacity-0" : "scale-100 opacity-100")}> {index + 1} </span> <svg viewBox="0 0 24 24" className="absolute h-4 w-4" fill="none" stroke="currentColor" strokeWidth="3.3" strokeLinecap="round" strokeLinejoin="round" aria-hidden> <path d="m5 12.5 4.5 4.5L19 7.5" pathLength={1} strokeDasharray={1} strokeDashoffset={done ? 0 : 1} className="transition-[stroke-dashoffset] delay-150 duration-[450ms] ease-[cubic-bezier(.16,1,.3,1)] motion-reduce:transition-none" /> </svg> </span> ); } /** * A step header plus the step's content. Finished steps turn into a check that draws itself in, the line * between steps fills with blue, and the content slides in from the side you're heading. */ export function Stepper({ steps, step, defaultStep = 0, onStepChange, clickable = true, complete, children, className }: StepperProps) { const [inner, setInner] = useState(defaultStep); const current = Math.max(0, Math.min(steps.length, step ?? inner)); const uid = useId(); // Track direction from the previous step (adjusting state during render, no effect needed). const [prev, setPrev] = useState(current); const [dir, setDir] = useState<1 | -1>(1); if (prev !== current) { setDir(current > prev ? 1 : -1); setPrev(current); } const goTo = (n: number) => { const next = Math.max(0, Math.min(steps.length, n)); if (next === current) return; if (step === undefined) setInner(next); onStepChange?.(next); }; const isComplete = current >= steps.length; const controls: StepperControls = { step: current, next: () => goTo(current + 1), back: () => goTo(current - 1), goTo, isFirst: current === 0, isLast: current === steps.length - 1, isComplete, }; const body = isComplete ? complete : steps[current]?.content; return ( <div className={cx("flex w-full flex-col", className)}> <style href="asta-stepper" precedence="asta">{KEYFRAMES}</style> <ol aria-label="Progress" className="flex items-start"> {steps.map((s, i) => { const state = i < current ? "done" : i === current ? "current" : "todo"; const canClick = clickable && state === "done" && !isComplete; const label = ( <> <Mark index={i} state={state} /> <span className={cx("min-w-0 flex-col text-left", state === "current" ? "flex" : "hidden sm:flex")}> <span className={cx("truncate text-[13px] font-medium tracking-[-0.01em] transition-colors duration-300", state === "todo" ? "text-mute" : "text-ink")}>{s.title}</span> {s.description && <span className="truncate text-[12px] text-mute">{s.description}</span>} </span> </> ); return ( <li key={s.title} aria-current={state === "current" ? "step" : undefined} className={cx("flex min-w-0 items-center", i < steps.length - 1 && "flex-1")}> {canClick ? ( <button type="button" onClick={() => goTo(i)} aria-label={`${s.title}, done. Go back to this step`} className="-m-1 flex min-w-0 items-center gap-2.5 rounded-lg p-1 outline-none transition-transform duration-200 hover:opacity-80 focus-visible:ring-2 focus-visible:ring-brand/50 active:scale-[0.98]" > {label} </button> ) : ( <span className="flex min-w-0 items-center gap-2.5"> {label} <span className="sr-only">{state === "done" ? ", done" : state === "todo" ? ", not started" : ""}</span> </span> )} {i < steps.length - 1 && ( <span aria-hidden className="relative mx-3 h-[2px] min-w-6 flex-1 overflow-hidden rounded-full bg-[color-mix(in_srgb,var(--color-ink)_10%,transparent)]"> <span className="absolute inset-0 origin-left rounded-full bg-brand transition-transform duration-500 ease-[cubic-bezier(.16,1,.3,1)] motion-reduce:transition-none" style={{ transform: `scaleX(${i < current ? 1 : 0})` }} /> </span> )} </li> ); })} </ol> <div className="mt-6 overflow-hidden"> <div key={current} id={`${uid}-panel`} role="region" aria-label={isComplete ? "Done" : steps[current]?.title} className={cx( "motion-reduce:!animate-none", dir === 1 ? "animate-[kit-step-next_.42s_cubic-bezier(.16,1,.3,1)_both]" : "animate-[kit-step-back_.42s_cubic-bezier(.16,1,.3,1)_both]", )} > {body} </div> </div> {children && <div className="mt-6">{typeof children === "function" ? children(controls) : children}</div>} </div> ); } export default Stepper;Or ask your AI agent
Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.
Add the Astabyte UI Stepper component to my project. Numbered steps that turn into checks. It includes: steps, check, progress line, back/next, complete. Install it: ```sh pnpm dlx asta-ui@latest add stepper --radix ``` Or with the shadcn CLI: ```sh pnpm dlx shadcn@latest add https://ui.astabyte.com/r/stepper.json ``` If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4). Import it like this: ```tsx import { Button } from "@/components/astabyte/button"; import { Stepper, type StepItem } from "@/components/astabyte/stepper"; ``` Usage example and props: https://ui.astabyte.com/stepper Full catalogue for context: https://ui.astabyte.com/llms.txt Rules: - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS. - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback. - Keep keyboard, focus and ARIA behaviour. - Use fake data and fake brand names in examples. Use it to: [describe where it goes and what it should do]Or use plain HTML + CSS
Not on React? Use it from Django, Rails, Laravel, Go
html/template, htmx or a static page. Loadasta.cssandasta.jsonce (thehead.htmltab), then paste the markup. Theui.astabyte.com/cdnlink is temporary: pin a version from jsDelivr for production. More in HTML + CSS.<!-- Needs asta.js: Back/Continue move data-step and set data-state on each step and panel. --> <div> <div class="asta-stepper" data-asta-stepper id="ex-step-one" data-step="0" data-count="3" data-first> <ol aria-label="Progress" class="asta-stepper-steps"> <li data-asta-step="0" data-state="current" aria-current="step" class="asta-stepper-step"><button type="button" data-asta-step-goto="0" disabled class="asta-stepper-goto"><span class="asta-stepper-mark"><span>1</span><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7" pathLength="1" stroke-dasharray="1"/></svg></span><span class="asta-stepper-text"><span class="asta-stepper-title">Account</span><span class="asta-stepper-desc">Your details</span></span><span class="asta-stepper-sr" data-for="done">, done</span><span class="asta-stepper-sr" data-for="todo">, not started</span></button><span aria-hidden="true" class="asta-stepper-line"><span></span></span></li> <li data-asta-step="1" data-state="todo" class="asta-stepper-step"><button type="button" data-asta-step-goto="1" disabled class="asta-stepper-goto"><span class="asta-stepper-mark"><span>2</span><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7" pathLength="1" stroke-dasharray="1"/></svg></span><span class="asta-stepper-text"><span class="asta-stepper-title">Workspace</span><span class="asta-stepper-desc">Name it</span></span><span class="asta-stepper-sr" data-for="done">, done</span><span class="asta-stepper-sr" data-for="todo">, not started</span></button><span aria-hidden="true" class="asta-stepper-line"><span></span></span></li> <li data-asta-step="2" data-state="todo" class="asta-stepper-step"><button type="button" data-asta-step-goto="2" disabled class="asta-stepper-goto"><span class="asta-stepper-mark"><span>3</span><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7" pathLength="1" stroke-dasharray="1"/></svg></span><span class="asta-stepper-text"><span class="asta-stepper-title">Invite</span><span class="asta-stepper-desc">Bring people</span></span><span class="asta-stepper-sr" data-for="done">, done</span><span class="asta-stepper-sr" data-for="todo">, not started</span></button></li> </ol> <div class="asta-stepper-panels"> <div role="region" aria-label="Account" data-asta-step-panel="0"><div style="border-radius:12px;background:var(--paper-2);padding:20px;font-size:14px">Name, email and a password.</div></div> <div role="region" aria-label="Workspace" data-asta-step-panel="1" hidden><div style="border-radius:12px;background:var(--paper-2);padding:20px;font-size:14px">Pick a name your team will see.</div></div> <div role="region" aria-label="Invite" data-asta-step-panel="2" hidden><div style="border-radius:12px;background:var(--paper-2);padding:20px;font-size:14px">Add teammates by email, or skip for now.</div></div> <div role="region" aria-label="Done" data-asta-step-panel="3" hidden><div style="border-radius:12px;background:var(--paper-2);padding:20px;font-size:14px">All set. Your Astabyte workspace is ready.</div></div> </div> <div class="asta-stepper-actions"><div class="asta-stepper-controls"> <button type="button" data-asta-step-back class="asta-btn asta-btn-outline asta-stepper-back"><span class="asta-btn-label">Back</span></button> <button type="button" data-asta-step-next class="asta-btn asta-btn-accent"><span class="asta-btn-label"><span class="asta-stepper-next-label">Continue</span><span class="asta-stepper-finish-label">Finish</span></span></button> </div></div> </div> </div>
Usage
The demo above, as code.
"use client";
import { useState } from "react";
import { Button } from "@/components/astabyte/button";
import { Stepper, type StepItem } from "@/components/astabyte/stepper";
function Row({ k, v }: { k: string; v: string }) {
return (
<div className="flex items-baseline justify-between gap-4 py-1.5 text-[13.5px]">
<span className="text-mute">{k}</span>
<span className="text-right tabular-nums text-ink">{v}</span>
</div>
);
}
function Choice({ title, sub, price, on, onPick }: { title: string; sub: string; price: string; on: boolean; onPick: () => void }) {
return (
<button
type="button"
role="radio"
aria-checked={on}
onClick={onPick}
className={
"flex w-full items-center justify-between gap-3 rounded-[10px] px-3.5 py-3 text-left outline-none transition-shadow duration-200 focus-visible:ring-2 focus-visible:ring-brand/50 " +
(on ? "shadow-[inset_0_0_0_1.5px_var(--color-brand)]" : "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_12%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_22%,transparent)]")
}
>
<span>
<span className="block text-[13.5px] font-medium text-ink">{title}</span>
<span className="block text-[12px] text-mute">{sub}</span>
</span>
<span className="text-[13px] tabular-nums text-ink">{price}</span>
</button>
);
}
export default function StepperDemo() {
const [step, setStep] = useState(0);
const [ship, setShip] = useState<"standard" | "express">("standard");
const shipping = ship === "express" ? 14 : 0;
const steps: StepItem[] = [
{
title: "Cart",
description: "2 items",
content: (
<div className="rounded-xl bg-paper-2 px-4 py-2">
<Row k="Linen overshirt · M" v="$89.00" />
<Row k="Canvas tote" v="$34.00" />
</div>
),
},
{
title: "Shipping",
description: "Delivery",
content: (
<div role="radiogroup" aria-label="Shipping" className="flex flex-col gap-2">
<Choice title="Standard" sub="3–5 business days" price="Free" on={ship === "standard"} onPick={() => setShip("standard")} />
<Choice title="Express" sub="Next business day" price="$14.00" on={ship === "express"} onPick={() => setShip("express")} />
</div>
),
},
{
title: "Payment",
description: "Card",
content: (
<div className="flex items-center gap-3 rounded-xl bg-paper-2 px-4 py-3.5">
<span className="flex h-7 w-10 items-center justify-center rounded-md bg-ink text-[9px] font-semibold tracking-[0.06em] text-paper">CARD</span>
<div className="min-w-0 flex-1">
<p className="text-[13.5px] font-medium text-ink">•••• 4242</p>
<p className="text-[12px] text-mute">Expires 08/29</p>
</div>
<span className="text-[12px] text-brand">Default</span>
</div>
),
},
{
title: "Review",
description: "Confirm",
content: (
<div className="rounded-xl bg-paper-2 px-4 py-2">
<Row k="Subtotal" v="$123.00" />
<Row k="Shipping" v={shipping ? `$${shipping}.00` : "Free"} />
<Row k="Total" v={`$${123 + shipping}.00`} />
</div>
),
},
];
return (
<div className="flex min-h-[420px] w-full items-center justify-center p-6 sm:p-10">
<div className="flex w-full max-w-lg flex-col gap-8">
<Stepper
steps={steps}
step={step}
onStepChange={setStep}
complete={
<div className="flex flex-col items-center gap-1 rounded-xl bg-paper-2 px-4 py-6 text-center">
<p className="text-[15px] font-medium tracking-[-0.01em] text-ink">Order placed</p>
<p className="text-[13px] text-mute">Order #10482 · a receipt is on its way.</p>
</div>
}
>
{({ back, next, isFirst, isLast, isComplete }) =>
isComplete ? (
<div className="flex justify-center">
<Button variant="outline" size="sm" onClick={() => setStep(0)}>
Start over
</Button>
</div>
) : (
<div className="flex items-center justify-between gap-3">
<Button variant="ghost" size="sm" onClick={back} disabled={isFirst}>
Back
</Button>
<Button variant={isLast ? "accent" : "solid"} size="sm" onClick={next}>
{isLast ? `Pay $${123 + shipping}.00` : "Continue"}
</Button>
</div>
)
}
</Stepper>
<p className="text-center text-[12.5px] text-mute">Click a finished step to go back to it.</p>
</div>
</div>
);
}