import type { ReactNode } from "react";
const states = {
done: { mark: "border-(--tui-stepper-done-bg) bg-(--tui-stepper-done-bg) text-(--tui-stepper-done-fg)", label: "text-(--tui-stepper-fg)", line: "bg-(--tui-stepper-done-bg)" },
current: { mark: "border-(--tui-stepper-current-border) bg-(--tui-stepper-bg) text-(--tui-stepper-fg)", label: "font-(--tui-stepper-current-weight) text-(--tui-stepper-fg)", line: "bg-(--tui-stepper-line)" },
upcoming: { mark: "border-(--tui-stepper-line) bg-(--tui-stepper-bg) text-(--tui-stepper-muted)", label: "text-(--tui-stepper-muted)", line: "bg-(--tui-stepper-line)" },
};
export interface StepperProps {
/** The steps, in order. */
steps: ReactNode[];
/** Which step is in progress, starting at 0. Everything before it is done. */
current: number;
label?: string;
className?: string;
}
export function Stepper({ steps, current, label = "Progress", className }: StepperProps) {
return (
<ol aria-label={label} className={["m-0 flex w-full list-none items-start p-0 font-(family-name:--tui-font) text-(length:--tui-stepper-font-size)", className].filter(Boolean).join(" ")}>
{steps.map((step, i) => {
const state = i < current ? "done" : i === current ? "current" : "upcoming";
const s = states[state];
return (
<li key={i} aria-current={state === "current" ? "step" : undefined} className="flex min-w-0 flex-1 flex-col items-center gap-(--tui-stepper-gap) last:flex-none">
<div className="flex w-full items-center">
<span data-slot="step" data-state={state} className={`flex size-(--tui-stepper-size) shrink-0 items-center justify-center rounded-(--tui-stepper-radius) border-solid border-(length:--tui-stepper-border-width) leading-none font-medium tabular-nums ${s.mark}`}>
{state === "done" ? (
<svg aria-hidden viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" className="size-[55%]">
<path d="M3.5 8.5l3 3 6-7" />
</svg>
) : (
i + 1
)}
</span>
{i < steps.length - 1 && <span aria-hidden className={`mx-(--tui-stepper-gap) h-(--tui-stepper-line-width) min-w-4 flex-1 ${s.line}`} />}
</div>
<span className={`self-start leading-tight ${s.label}`}>
<span className="sr-only">{state === "done" ? "Done: " : state === "current" ? "Current: " : ""}</span>
{step}
</span>
</li>
);
})}
</ol>
);
}:root {
color-scheme: light;
--tui-bg: #ffffff;
--tui-fg: #0a0a0a;
--tui-muted: #f5f5f5;
--tui-muted-fg: #737373;
--tui-border: #e5e5e5;
--tui-primary: #171717;
--tui-primary-fg: #fafafa;
--tui-ring: #a3a3a3;
--tui-success: #16a34a;
--tui-warning: #d97706;
--tui-danger: #dc2626;
--tui-radius: 8px;
--tui-border-width: 1px;
--tui-space: 4px;
--tui-shadow: none;
--tui-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--tui-text: 14px;
--tui-duration: 150ms;
/* Stepper */
--tui-stepper-size: calc(var(--tui-space) * 7);
--tui-stepper-gap: calc(var(--tui-space) * 2);
--tui-stepper-line-width: 2px;
--tui-stepper-border-width: 2px;
--tui-stepper-radius: 999px;
--tui-stepper-font-size: 13px;
--tui-stepper-bg: var(--tui-bg);
--tui-stepper-fg: var(--tui-fg);
--tui-stepper-muted: var(--tui-muted-fg);
--tui-stepper-line: var(--tui-border);
--tui-stepper-done-bg: var(--tui-primary);
--tui-stepper-done-fg: var(--tui-primary-fg);
--tui-stepper-current-border: var(--tui-primary);
--tui-stepper-current-weight: 600;
}
.dark,
[data-theme="dark"] {
color-scheme: dark;
--tui-bg: #0a0a0a;
--tui-fg: #fafafa;
--tui-muted: #1c1c1c;
--tui-muted-fg: #a3a3a3;
--tui-border: #2a2a2a;
--tui-primary: #fafafa;
--tui-primary-fg: #171717;
--tui-ring: #737373;
--tui-success: #22c55e;
--tui-warning: #f59e0b;
--tui-danger: #ef4444;
}Needs Tailwind CSS v4. Import the stylesheet once, after Tailwind.