- LaralCN-UI: shadcn-style Blade components and blocks you own · part 18 of 26
- Laravel
- Blade
- LaralCN-UI
- Accessibility
LaralCN-UI stepper: a component with no JavaScript on purpose
The LaralCN-UI stepper shows progress through a multi-step flow like a checkout or a signup, horizontal or vertical, with completed, current, upcoming and failed steps. It is the only one of the new components with no script at all, because the step a user is on belongs to the server.
4 min read
stepper draws a row or column of numbered steps joined by lines, with each step marked complete, current, upcoming or failed. You pass the steps and a current number, and it renders an ordered list. Out of the six new components in PR #7 it is the smallest, about 130 lines, and the only one with no <script> block.
The server already knows the step
Every other new component in that batch reacts to clicks: the combobox filters as you type, and the data table sorts when you press a header. A stepper does not need to. In a Laravel checkout or signup, the step a user is on comes from the session or the URL, and it changes when the server accepts a form and redirects. A client-side stepper would have to be told that number anyway, and then it could drift from what the server thinks.
So the component takes current and nothing else decides it:
<x-ui.stepper :steps="['Account', 'Billing', 'Confirm']" :current="2" />
The usage example shows the controller side, which is where the logic really lives:
public function store(Request $request)
{
// validate the current step, then move on
return redirect()->route('signup', ['step' => $request->integer('step') + 1]);
}
current is 1-based. Passing a number past the last step marks every step complete, which is how the "Delivered" demo shows a finished order.
Four states from one match
Each step's state comes from a single match (true), with the error check first so a failed step wins over everything else:
$state = match (true) {
$error !== null && (int) $error === $number => 'error',
$number < (int) $current => 'complete',
$number === (int) $current => 'current',
default => 'upcoming',
};
The state then picks whole class strings for the circle and the title, following the project rule that every Tailwind class is written out in full in the source. A complete step gets a filled primary circle with a check mark, the current one gets a primary ring, a failed one turns destructive with an X, and upcoming steps stay muted. Each <li> also carries data-state, so you can restyle any state from outside without touching the file.
Steps can be plain strings or arrays with a title, a description and an href. The href is only used when the step is complete:
// Only finished steps link back; the user cannot skip ahead.
'href' => $state === 'complete' ? $step['href'] ?? null : null,
That gives you "go back and edit your address" for free, without letting anyone click ahead to the payment step before the account step has passed validation.
What a screen reader hears
The list is an <ol> with an aria-label (default "Progress"), so it is announced as a list with a count. The current step has aria-current="step". The circles and connector lines are aria-hidden, because a check mark or a coloured line means nothing when read out. Instead, each title carries a visually hidden status word:
{{ $item['title'] }}
<span class="sr-only">({{ $labels[$item['state']] }})</span>
The words default to Completed, Current, Upcoming and Error, and the labels prop overrides them. The usage example passes Arabic ones ('complete' => 'مكتمل' and so on), since a stepper on an Arabic page should not announce English status words.
Lines that run the right way in Arabic
The connector between two steps is an absolutely positioned line. In a horizontal stepper it starts just past one circle and ends just before the next. Writing that with left and right would draw the lines on the wrong side in a right-to-left page, so it uses the logical properties from the RTL work in part 9:
'absolute top-4 start-[calc(50%+1.5rem)] end-[calc(-50%+1.5rem)] h-px'
In vertical mode the line runs down from start-[calc(1rem-0.5px)], which centres a 1px line under a 2rem circle on whichever side the text starts. Nothing in the stepper needs an rtl: variant, because there are no transforms or arrows to flip. A connector turns primary once the step before it is complete, so the coloured part of the track always ends at the current step.
Where it is
composer require --dev safi/laralcn-ui
php artisan ui:init
php artisan ui:add stepper
Docs and demos: https://laralcn-ui.abdulkadersafi.com/components/stepper (Arabic at /ar/components/stepper). Source: https://github.com/Abdulkader-Safi/LaralCN-UI. MIT licensed. shadcn has no stepper, so this one is designed from scratch rather than ported.
Next: the toast queue, an upgrade to the existing toast with variants, loading states and a stack.
Last updated 1 Dec 2026 · filed under Laravel, blade, laralcn-ui, accessibility