Created
July 9, 2023 03:34
-
-
Save darylwright/018a3e8996d8e2c215bf184fa68b0791 to your computer and use it in GitHub Desktop.
This is an implementation of theming in a Next.js app using the App Router API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ReactNode, ReactElement} from "react"; | |
import RootComponent from "@/components/root"; | |
export default function RootLayout({ children }: { children: ReactNode }): ReactElement { | |
return ( | |
<html suppressHydrationWarning> | |
<body> | |
<RootComponent> | |
{children} | |
</RootComponent> | |
</body> | |
</html> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import {ReactNode, ReactElement} from "react"; | |
import {ThemeProvider} from "@wits/next-themes"; | |
type RootProps = { | |
children: ReactNode; | |
} | |
export default function RootComponent({ children }: RootProps): ReactElement { | |
return ( | |
<ThemeProvider attribute="class" themes={[`light`, `dark`]} enableSystem> | |
{children} | |
</ThemeProvider> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment