mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 11:31:09 -05:00
28 lines
900 B
PHP
28 lines
900 B
PHP
<label for="theme-toggle" class="cursor-pointer">
|
|
<input
|
|
type="checkbox"
|
|
id="theme-toggle"
|
|
class="hidden"
|
|
wire:model.live="isDark"
|
|
wire:change="toggleTheme"
|
|
>
|
|
<div
|
|
class="inline-flex items-center justify-center p-2 text-gray-500 transition-colors hover:text-primary dark:text-gray-400 dark:hover:text-primary theme-toggle-btn"
|
|
role="button"
|
|
aria-label="Toggle dark mode"
|
|
>
|
|
<i class="text-xl fas {{ $isDark ? 'fa-sun' : 'fa-moon' }}"></i>
|
|
</div>
|
|
</label>
|
|
|
|
<script>
|
|
document.addEventListener('livewire:init', () => {
|
|
Livewire.on('theme-changed', ({ theme }) => {
|
|
if (theme === 'dark') {
|
|
document.documentElement.classList.add('dark');
|
|
} else {
|
|
document.documentElement.classList.remove('dark');
|
|
}
|
|
});
|
|
});
|
|
</script> |