diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index db5adfa1..0afb8558 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -31,6 +31,32 @@ export default function RootLayout({
lang="en"
suppressHydrationWarning
>
+
+
+
{
const root = window.document.documentElement;
- root.classList.remove("light", "dark");
-
+ // Determine the target theme
+ let targetTheme: string;
if (theme === "system") {
- const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
- .matches
+ targetTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
- root.classList.add(systemTheme);
} else {
- root.classList.add(theme);
+ targetTheme = theme;
+ }
+
+ // Only apply theme if it's not already present
+ if (!root.classList.contains(targetTheme)) {
+ root.classList.remove("light", "dark");
+ root.classList.add(targetTheme);
}
}, [theme]);
diff --git a/apps/web/src/components/ui/sonner.tsx b/apps/web/src/components/ui/sonner.tsx
index 9e6b9b8a..e17dc90a 100644
--- a/apps/web/src/components/ui/sonner.tsx
+++ b/apps/web/src/components/ui/sonner.tsx
@@ -1,4 +1,4 @@
-import { useTheme } from "next-themes";
+import { useTheme } from "@/components/theme-provider";
import { Toaster as Sonner, ToasterProps } from "sonner";
const Toaster = ({ ...props }: ToasterProps) => {