Skip to content

Commit db9a598

Browse files
committed
Fix theme toggle functionality and set dark mode as default
- Created Providers component as client component wrapper for ThemeProvider - Fixed theme toggle button not working (Server/Client Component conflict) - Set default theme to dark mode instead of system preference - Theme toggle now properly switches between dark and light modes
1 parent 6948c99 commit db9a598

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Metadata } from "next";
2-
import { ThemeProvider } from "next-themes";
32
import { VT323, Share_Tech, Inter } from "next/font/google";
43
import { Analytics } from "@vercel/analytics/react";
54
import { SpeedInsights } from "@vercel/speed-insights/next";
65
import { GoogleAnalytics } from "@/components/GoogleAnalytics";
6+
import { Providers } from "@/components/Providers";
77
import "./globals.css";
88

99
// Font configurations
@@ -165,9 +165,9 @@ export default function RootLayout({
165165
/>
166166
</head>
167167
<body className={`${inter.variable} ${vt323.variable} ${shareTech.variable} antialiased font-sans`}>
168-
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
168+
<Providers>
169169
{children}
170-
</ThemeProvider>
170+
</Providers>
171171
<Analytics />
172172
<SpeedInsights />
173173
<GoogleAnalytics />

components/Providers.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use client";
2+
3+
import { ThemeProvider } from "next-themes";
4+
import { ReactNode } from "react";
5+
6+
export function Providers({ children }: { children: ReactNode }) {
7+
return (
8+
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem={false}>
9+
{children}
10+
</ThemeProvider>
11+
);
12+
}

0 commit comments

Comments
 (0)