Skip to main content

wire:loading Indicator

Premium
2 min read

Imagine you have big data that needs to be loaded into a table. Besides the Lazy Loading component, another method uses wire:loading directive which has a bit more features.


First, add a div element with the wire:loading directive above the table.

resources/views/livewire/products.blade.php:

<div class="space-y-6">
<div class="space-x-8">
// ...
</div>
<div class="text-red-600" wire:loading>Loading...</div>
<div class="min-w-full align-middle">
// ...
</div>
{{ $products->links() }}
</div>

Simulate longer loading by adding sleep(1) to the Livewire component render method. Then try to search, and you should see a...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (36 h 00 min)

You also get:

61 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Nurbek avatar

why, when I write something, the first time the download works and gives out posts, the next process does not work just loading and opacity-50

Modestas avatar

Can you expand on this? Not sure I fully understand what you had in mind

Francisco Ferreira Roque Júnior avatar
Francisco Ferreira Roque Júnior

Hey Polivas, The "You can target a specific action by adding the wire:target="methodName" directive." looks like don't belongs to this class, but if it does, sorry, I just don't understand the context.

Thanks sir.

Nerijus avatar

In this example we have a button with an action remove. Where we use wire:loading we alsp use the wire:target and specify that remove method. This means while remove is being executed the wire:loading div will be active. Hope this helps.

Francisco Ferreira Roque Júnior avatar
Francisco Ferreira Roque Júnior

Thank you very much Nerijus, now I understood the point.

Hossam Mohamed avatar

I search for the lesson of how to make the loading indicator at Livewire , alpine js and Js I see this lesson at laraveldaily but now i can't get useful result from the search

Nerijus avatar

If you need help will need more than that

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.