Application
Progress Steps
Horizontal or vertical stepper with complete / current / upcoming states.
Motioncompleted check scale-in on spring.bouncy
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { ProgressSteps } from "kineto/progress-steps";Preview
tsx
"use client";
import * as React from "react";
import { Check, type LucideIcon } from "lucide-react";
import { motion, useReducedMotion } from "motion/react";
import { cn } from "@/lib/cn";
import { spring } from "@/lib/motion-presets";
export interface Step {
title: string;
description?: string;
icon?: LucideIcon;
}
export interface ProgressStepsProps extends React.HTMLAttributes<HTMLElement> {
steps: Step[];
/** Index of the active step (0-based). Earlier steps render as complete. */
current: number;
orientation?: "horizontal" | "vertical";
}
function StepCircle({
state,
index,
icon: Icon,
reduced,
}: {
state: "complete" | "current" | "upcoming";
index: number;
icon?: LucideIcon;
reduced: boolean;
}) {
return (
<span
className={cn(
"flex size-9 shrink-0 items-center justify-center rounded-full text-sm font-medium",
state === "complete" && "bg-brand text-brand-foreground",
state === "current" && "border-2 border-brand bg-brand/10 text-brand",
state === "upcoming" && "border border-border bg-card text-muted-foreground"
)}
>
{state === "complete" ? (
<motion.span
initial={reduced ? false : { scale: 0.5, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={spring.bouncy}
>
<Check className="size-4" strokeWidth={3} />
</motion.span>
) : Icon ? (
<Icon className="size-4" />
) : (
index + 1
)}
</span>
);
}
const ProgressSteps = React.forwardRef<HTMLElement, ProgressStepsProps>(
({ className, steps, current, orientation = "horizontal", ...props }, ref) => {
const reduced = useReducedMotion() ?? false;
const stateOf = (i: number): "complete" | "current" | "upcoming" =>
i < current ? "complete" : i === current ? "current" : "upcoming";
if (orientation === "vertical") {
return (
<nav ref={ref} aria-label="Progress" className={className} {...props}>
<ol className="flex flex-col">
{steps.map((step, i) => {
const last = i === steps.length - 1;
return (
<li key={i} className="flex gap-3">
<div className="flex flex-col items-center">
<StepCircle state={stateOf(i)} index={i} icon={step.icon} reduced={reduced} />
{!last ? (
<div
className={cn(
"my-1 min-h-8 w-0.5 flex-1 rounded-full",
i < current ? "bg-brand" : "bg-border"
)}
/>
) : null}
</div>
<div className={cn(last ? "" : "pb-6")}>
<p
className={cn(
"text-sm font-medium",
i <= current ? "text-foreground" : "text-muted-foreground"
)}
>
{step.title}
</p>
{step.description ? (
<p className="mt-0.5 text-sm text-muted-foreground">
{step.description}
</p>
) : null}
</div>
</li>
);
})}
</ol>
</nav>
);
}
return (
<nav ref={ref} aria-label="Progress" className={className} {...props}>
<ol className="flex w-full">
{steps.map((step, i) => {
const last = i === steps.length - 1;
return (
<li key={i} className={cn(last ? "flex-none" : "flex-1")}>
<div className="flex items-center">
<StepCircle state={stateOf(i)} index={i} icon={step.icon} reduced={reduced} />
{!last ? (
<div
className={cn(
"mx-2 h-0.5 flex-1 rounded-full",
i < current ? "bg-brand" : "bg-border"
)}
/>
) : null}
</div>
<div className="mt-2 pr-4">
<p
className={cn(
"text-sm font-medium",
i <= current ? "text-foreground" : "text-muted-foreground"
)}
>
{step.title}
</p>
{step.description ? (
<p className="mt-0.5 text-xs text-muted-foreground">
{step.description}
</p>
) : null}
</div>
</li>
);
})}
</ol>
</nav>
);
}
);
ProgressSteps.displayName = "ProgressSteps";
export { ProgressSteps };src/components/ui/progress-steps.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| steps | { title; description?; icon? }[] | — | The steps. |
| current | number | — | Active step index (0-based). |
| orientation | "horizontal" | "vertical" | "horizontal" | Layout. |