Laravel tailwind livewire alpine question
I'm working on a dark mode, light mode theme livewire mode changer with user preference stored in the user table in a string called mode.
Everything worked using main class="{{ auth()->user()->mode }}" until I moved the main tag into the layouts.app - So how do I change main class="light" to main class="dark" when it is outside of the livewire component using alpinejs without a page refresh?
Hi there,
I think that this should be doable with a Livewire Event and a JavaScript listener. So that you could trigger an event from your Livewire componenet and have a JS listener to change the class:
https://laravel-livewire.com/docs/2.x/events
Hope that this helps! Regards, Bobby