Abdulkader Safi

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

Share
Three LaralCN-UI steppers: a horizontal checkout flow on step three, a vertical import flow with a failed step, and a vertical delivery flow with every step complete.

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

Every entry on this project

26 build notes, in order

Including the ones where nothing worked. You are on part 18.

Read the series →

FAQ

Frequently asked questions

How do I move the user to the next step?

In your controller. Validate the current step, store or redirect with the next step number, and render the stepper with that number as current.

Can users click back to an earlier step?

Yes, if you give that step an href. Links only render on completed steps, so nobody can skip ahead.

How do I show that a step failed?

Pass its 1-based number as error, for example :error="2". That step turns red with an X and its hidden status word becomes "Error".

Does it work in right-to-left pages?

Yes. The connector lines use logical start and end positions, so they mirror under dir="rtl" with no extra classes.

Written by

Abdulkader Safi

Software Engineer

Lead engineer at DSRPT, from Lebanon and based in Kuwait. I write about the tools and bugs from real client work, with the numbers I measured.

About me → GitHub LinkedIn

Need this kind of work done on your project?

Start a project →

Keep reading

More from LaralCN-UI: shadcn-style Blade components and blocks you own

All 26 entries →