---
title: "stepper"
description: "Shows progress through a multi-step flow: completed, current, upcoming and failed steps, horizontal or vertical."
category: "Navigation"
---
# stepper
Shows progress through a multi-step flow: completed, current, upcoming and failed steps, horizontal or vertical.
## Installation
```bash
php artisan ui:add stepper
```
## Dependencies
- composer: `gehrisandro/tailwind-merge-laravel`
## Usage
```blade
{{-- With descriptions, links back to finished steps, vertical. --}}
{{-- A failed step, plus translated screen-reader labels. --}}
{{-- The controller owns the step. No JavaScript involved:
public function show(Request $request)
{
$step = min(max((int) $request->query('step', 1), 1), 3);
return view('signup', ['step' => $step]);
}
public function store(Request $request)
{
// validate the current step, then move on
return redirect()->route('signup', ['step' => $request->integer('step') + 1]);
}
--}}
```
## Example
The demo rendered on the docs page.
```blade
@php
// Normally comes from the controller, e.g. the checkout step stored in the session.
$steps = [
['title' => 'Account', 'description' => 'Your details', 'href' => '#account'],
['title' => 'Shipping', 'description' => 'Where it goes', 'href' => '#shipping'],
['title' => 'Payment', 'description' => 'Card or transfer'],
['title' => 'Confirm', 'description' => 'Review and place'],
];
@endphp
```
## Source
Copy this file to the path shown above it.
`resources/views/components/ui/stepper.blade.php`
```blade
@props([
// Strings, or ['title' => ..., 'description' => ..., 'href' => ...].
'steps' => [],
// 1-based index of the active step. Past the last step = all complete.
'current' => 1,
'orientation' => 'horizontal',
// 1-based index of a step that failed, or null.
'error' => null,
'label' => 'Progress',
'labels' => [],
])
@php
$labels = array_merge(
[
'complete' => 'Completed',
'current' => 'Current',
'upcoming' => 'Upcoming',
'error' => 'Error',
],
$labels,
);
$vertical = $orientation === 'vertical';
$classes = \TailwindMerge\Laravel\Facades\TailwindMerge::merge(
$vertical ? 'flex flex-col' : 'flex w-full items-start',
$attributes->get('class'),
);
$items = [];
foreach (array_values($steps) as $index => $step) {
$number = $index + 1;
$step = is_array($step) ? $step : ['title' => $step];
$state = match (true) {
$error !== null && (int) $error === $number => 'error',
$number < (int) $current => 'complete',
$number === (int) $current => 'current',
default => 'upcoming',
};
$items[] = [
'number' => $number,
'title' => $step['title'] ?? '',
'description' => $step['description'] ?? null,
// Only finished steps link back; the user cannot skip ahead.
'href' => $state === 'complete' ? $step['href'] ?? null : null,
'state' => $state,
'last' => $number === count($steps),
'connector' => $number < (int) $current ? 'complete' : 'upcoming',
];
}
@endphp
except('class')->merge(['class' => $classes]) }}>
@foreach ($items as $item)
@php
$indicator = match ($item['state']) {
'complete' => 'bg-primary text-primary-foreground border-primary',
'current' => 'border-primary bg-background text-primary ring-4 ring-primary/20',
'error' => 'bg-destructive text-destructive-foreground border-destructive',
default => 'border-input bg-background text-muted-foreground',
};
$title = match ($item['state']) {
'upcoming' => 'text-muted-foreground',
'error' => 'text-destructive',
default => 'text-foreground',
};
$connector = match ($item['connector']) {
'complete' => 'bg-primary',
default => 'bg-border',
};
$tag = $item['href'] ? 'a' : 'div';
@endphp
@unless ($item['last'])
{{-- Logical start/end, so the line runs the right way in RTL. --}}
@endunless
<{{ $tag }} @if ($item['href']) href="{{ $item['href'] }}" @endif
class="{{ $vertical ? 'flex gap-3' : 'flex flex-col items-center gap-2' }} rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 {{ $item['href'] ? 'group/step' : '' }}">
@if ($item['state'] === 'complete')
@elseif ($item['state'] === 'error')
@else
{{ $item['number'] }}
@endif
{{ $item['title'] }}
({{ $labels[$item['state']] }})
@if ($item['description'])
{{ $item['description'] }}
@endif
{{ $tag }}>
@endforeach
```
## Theme tokens
`--primary`, `--primary-foreground`, `--destructive`, `--destructive-foreground`, `--border`, `--input`, `--background`, `--foreground`, `--muted-foreground`, `--ring`
Pure markup, no JavaScript: the server decides `current` (1-based; past the last step marks all complete). `steps` takes strings or `['title', 'description', 'href']` arrays; `href` only links completed steps. `orientation` is `horizontal` or `vertical`, `error` marks a failed step, and `labels` overrides the screen-reader status words (`complete`, `current`, `upcoming`, `error`).