spatie/laravel-livewire-wizard
Lightweight Livewire components for building multi-step wizards in Laravel. Define a wizard with an ordered list of step components, each with its own screen and Livewire logic, and guide users through checkout-style flows with ease.
Any step component has a $steps property that contains an array containing information on all steps in the wizard. You can use $steps to build any navigation you want. Here's an example:
{{-- somewhere in a Blade view--}}
<ul>
[@foreach](https://github.com/foreach)($steps as $step)
<li
class="{{ $step->isCurrent() ? 'text-bold' : '' }}"
[@if](https://github.com/if) ($step->isPrevious())
wire:click="{{ $step->show() }}"
[@endif](https://github.com/endif)
>{{ $step->label }}</li>
[@endforeach](https://github.com/endforeach)
</ul>
Each entry in the array contains an instance of Spatie\LivewireWizard\Support\Step. It has these methods:
isCurrent(): returns true if this step is currently being displayedisPrevious(): returns true if this step comes before the step that's currently displayedisNext(): returns true if this step comes after the step that's currently displayedshow(): return the string that can be passed to wire:click to show the stepIn the example above, you see that we've used $step->label to render the content of the <li>.
That label property isn't available by default.
You can add any property on a step by adding a stepInfo method your Step component. That method should contain an array with properties regarding your step.
// in your step component
public function stepInfo(): array
{
return [
'label' => 'Your cart',
'icon' => 'fa-shopping-cart',
];
}
Any key you return will be available as a property on step.
$step->label; // returns 'Your cart'
$step->icon; // returns 'fa-shopping-cart'
How can I help you explore Laravel packages today?