Detect dark theme in Blade
How do I detect if dark theme is enabled in a Blade template, so I can display a different version of an image? I'm overriding Filament's logo.blade.php to show the client's logo top left, but need to display different versions depending on dark or light theme.
Solution:Jump to solution
Oooooh! You mean like do it how it tells me to in the documentation?
Derp.
sigh...
6 Replies
You could make it an alpine component and read it from the alpine store or from local storage.
I could what now? Eli5?
I was hoping there was a pseudo selector for classes like dark:hidden and dark:visible, but that doesn't seem to work.
Solution
Oooooh! You mean like do it how it tells me to in the documentation?
Derp.
sigh
https://filamentphp.com/docs/2.x/admin/appearance#dark-mode
on v3 it is
@theme-changed.window="..."
you can get the current mode with this document.querySelector('html').matches('.dark') ? 'dark' : 'light'
Thankyou!
how can I get the trigger of the filament's dark-light toggle button? Anyone?