Persist theme before hydration
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
(() => {
|
||||
try {
|
||||
const stored = window.localStorage.getItem("claw.theme");
|
||||
const mode =
|
||||
stored === "light" || stored === "dark" || stored === "system"
|
||||
? stored
|
||||
: "system";
|
||||
const prefersDark = window.matchMedia(
|
||||
"(prefers-color-scheme: dark)",
|
||||
).matches;
|
||||
const shouldUseDark = mode === "dark" || (mode === "system" && prefersDark);
|
||||
document.documentElement.classList.toggle("dark", shouldUseDark);
|
||||
} catch (_) {}
|
||||
})();
|
||||
Reference in New Issue
Block a user