Stepper
Also called multi-step form, wizard, or step indicator
A multi-step flow with a row of numbered steps, like Account, Profile, Done, that shows where you are and how many steps are left.
import { useState, type ReactNode } from 'react';
import { motion } from 'motion/react';
type Step = { title: string; content: ReactNode; complete: boolean };
type Props = { steps: Step[]; onFinish: () => void };
const CIRCLE =
'flex size-8 items-center justify-center rounded-full border text-muted-foreground transition-colors duration-300 group-data-done:border-blue-600 group-data-done:bg-blue-600 group-data-done:text-white aria-[current=step]:border-2 aria-[current=step]:border-blue-600 aria-[current=step]:text-blue-600';
const LINE =
'relative h-0.5 flex-1 bg-muted group-last:hidden before:absolute before:inset-0 before:origin-left before:scale-x-0 before:bg-blue-600 before:transition-transform before:duration-300 group-data-done:before:scale-x-100';
// Each step's content stays mounted in the parent's state, so Back keeps what was typed.
export function Stepper({ steps, onFinish }: Props) {
const [[index, direction], setIndex] = useState<[number, number]>([0, 1]);
const go = (next: number) => setIndex([next, next > index ? 1 : -1]);
const last = index === steps.length - 1;
return (
<div className='flex w-96 flex-col gap-6 text-sm'>
<ol className='flex items-center gap-2 *:flex *:items-center *:gap-2 *:not-last:flex-1'>
{steps.map(({ title }, i) => (
<li key={title} data-done={i < index || undefined} className='group'>
<span aria-current={i === index && 'step'} className={CIRCLE}>
{i < index ? '✓' : i + 1}
</span>
{title}
<span className={LINE} />
</li>
))}
</ol>
{/* The new step slides in from the side you're heading toward. */}
<motion.div
key={index}
initial={{ x: direction * 24, opacity: 0 }}
animate={{ x: 0, opacity: 1 }}
>
{steps[index]?.content}
</motion.div>
<div className='flex justify-between'>
<button
disabled={index === 0}
onClick={() => go(index - 1)}
className='px-4 py-2 disabled:invisible'
>
Back
</button>
<button
disabled={!steps[index]?.complete}
onClick={() => (last ? onFinish() : go(index + 1))}
className='rounded-lg bg-primary px-4 py-2 text-primary-foreground disabled:opacity-50'
>
{last ? 'Finish' : 'Next'}
</button>
</div>
</div>
);
}Split the signup into a 3-step stepper: Account, Profile, Done. Show numbered circles joined by a line at the top; finished steps turn into a checkmark and the connecting line fills in blue over 300ms. Next validates the current step before advancing, Back keeps what was entered, and the step content slides 24px and fades in the direction of travel over 250ms.
Paste into Layerwise or any AI coding tool.
What is Stepper?
A stepper splits a long task into a few short screens and shows a progress indicator on top: numbered circles joined by a line, with finished steps checked off, the current one highlighted, and the rest grayed out. Next and Back buttons move between steps.
Use it for tasks with a natural order that would feel overwhelming as one long form: onboarding, checkout, creating a project, connecting an integration. Three to five steps works best; with more, people start to wonder how long it will take.
Validate each step before moving on, keep what people entered when they go back, and let them click a finished step to return to it. Slide the content in the direction of travel, to the left for Next and to the right for Back, so the motion matches the indicator.
Often confused with
- Tabs
- Tabs let people switch between views in any order. A stepper walks them through steps in a set order and remembers which are done.
- Breadcrumb
- A breadcrumb shows where a page sits in a site and links back up the hierarchy. A stepper tracks progress through one task.
Related terms
All termsProgress bar
A horizontal bar that fills from left to right to show how much of a task is done, or slides in a loop while the total is still unknown.
Tabs
A row of labels that switches between panels of related content in the same spot, showing one panel at a time.
Direction-aware transition
A transition that slides new content in from the side you are heading toward, so going forward and going back move in opposite directions.
Inline validation
Form checking that happens right next to each field as you fill it in, showing an error or a checkmark before you press Submit.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.