-
-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme briefly flashes light mode #1506
Comments
Here is a video. Screen.Recording.2024-11-06.at.17.47.53.mov |
To fix this problem u'd have to persist in cache or Laravel session the I'll do a spike on implementing |
Thanks for replying. So I should just store the choice in cache and then use |
Or do you have a basic example? Happy to sponser you. |
@harrisonratcliffe are u using Laravite + Vite + SSR mode? (check 1. https://laravel.com/docs/11.x/vite#ssr, 2. https://inertiajs.com/server-side-rendering) |
Yep I am using InertiaJS SSR. |
After many failures, it seems so hard to inject JSX to HTML on-the-fly before page load with Inertia + SSR, which leaves us with one last option (dirty and will be deprecated in the future due to #1498 ): open <script data-flowbite-theme-mode-script>
try {
const mode = window.localStorage.getItem("flowbite-theme-mode") ?? "light";
const computedMode =
mode === "auto" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : mode;
if (computedMode === "dark") {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
} catch (e) {}
</script> ^ this is exactly what |
Ok, I've just found this when trying to resolve the white flicker when in dark mode and discovered the component which has resolved the issue for me. Remix SSR. Searching the docs I found it on the Remix page which makes sense, must have missed it when I set the project up. Thanks and leaving this here for anyone else in future. |
Steps to reproduce
Current behavior
The theme briefly shows as light mode if in dark mode and then flicks to the expected mode (dark). This doesn't happen in light mode.
Expected behavior
No flash when in dark mode like it does in light mode
Context
I'm using this in my layout:
I use Laravel/InertiaJS/React
Has anyone else experienced this or know how to resolve it?
The text was updated successfully, but these errors were encountered: