You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's sometimes important to notify a user if they have lost their internet connection. Livewire provides helpful utilities to perform actions based on a user's "offline" state.
## Toggling elements {#toggling-elements}
You can show an element on the page when the user goes "offline", by adding the `wire:offline` attribute.
@component('components.code')
<div wire:offline>
You are now offline.
</div>
@endcomponent
This `<div>` will automatically be hidden by default, and shown to the user when the browser goes offline.
## Toggling classes {#toggling-classes}
Adding the `class` modifier allows you to add a class to an element when "offline".
@component('components.code', ['lang' => 'html'])
<div wire:offline.class="bg-red-300"></div>
@endcomponent
Now, when the browser goes offline, the element will receive the `bg-red-300` class. The class will be removed again once the user is back online.
You can also perform the inverse, and remove classes by adding the `.remove` modifier, similar to how `wire:loading` works.