Components / Feedback
Stepper
Step-by-step progress with drawing checkmarks, filling connectors and a pulsing current step.
- Cart
- 2Shipping
- 3Payment
- 4Review
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/stepper.tsx. - 3
Use it
example.tsx"use client"; import { useState } from "react"; import { Stepper } from "@/components/ui/stepper"; const steps = ["Cart", "Shipping", "Payment", "Review"]; const button = "rounded-lg border border-zinc-200 bg-white px-3 py-1.5 text-sm text-zinc-700 transition hover:bg-zinc-100 disabled:opacity-40 dark:border-white/10 dark:bg-zinc-900 dark:text-zinc-200 dark:hover:bg-zinc-800"; export default function StepperDemo() { const [current, setCurrent] = useState(1); return ( <div className="flex w-full max-w-md flex-col items-center gap-8"> <Stepper steps={steps} current={current} /> <div className="flex gap-2"> <button type="button" className={button} disabled={current === 0} onClick={() => setCurrent((c) => c - 1)}> Back </button> <button type="button" className={button} disabled={current === steps.length} onClick={() => setCurrent((c) => c + 1)}> {current >= steps.length - 1 ? "Finish" : "Next"} </button> </div> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| steps | string[] | — | Step labels. |
| current | number | — | Index of the current step; earlier steps show as done. |