File tree Expand file tree Collapse file tree 9 files changed +310
-22
lines changed Expand file tree Collapse file tree 9 files changed +310
-22
lines changed Original file line number Diff line number Diff line change 9
9
"lint" : " next lint"
10
10
},
11
11
"dependencies" : {
12
+ "@radix-ui/react-dropdown-menu" : " ^2.1.1" ,
12
13
"@radix-ui/react-slot" : " ^1.1.0" ,
13
14
"class-variance-authority" : " ^0.7.0" ,
14
15
"clsx" : " ^2.1.1" ,
15
16
"lucide-react" : " ^0.403.0" ,
16
17
"next" : " 14.2.4" ,
18
+ "next-themes" : " ^0.3.0" ,
17
19
"react" : " ^18" ,
18
20
"react-dom" : " ^18" ,
19
21
"tailwind-merge" : " ^2.4.0" ,
Original file line number Diff line number Diff line change 1
1
import type { Metadata } from "next" ;
2
2
import "./globals.css" ;
3
- import { Inter as FontSans } from "next/font/google"
4
- import { cn } from "@/lib/utils"
5
-
6
-
7
- const fontSans = FontSans ( {
8
- subsets : [ "latin" ] ,
9
- variable : "--font-sans" ,
10
- } )
3
+ import { ThemeProvider } from "@/components/theme-provider"
11
4
12
5
export const metadata : Metadata = {
13
6
title : "Create Next App" ,
@@ -20,13 +13,16 @@ export default function RootLayout({
20
13
children : React . ReactNode ;
21
14
} > ) {
22
15
return (
23
- < html lang = "en" >
24
- < body
25
- className = { cn (
26
- "min-h-screen bg-background font-sans antialiased" ,
27
- fontSans . variable
28
- ) }
29
- > { children }
16
+ < html lang = "en" suppressHydrationWarning >
17
+ < body >
18
+ < ThemeProvider
19
+ attribute = "class"
20
+ defaultTheme = "system"
21
+ enableSystem
22
+ disableTransitionOnChange
23
+ >
24
+ { children }
25
+ </ ThemeProvider >
30
26
</ body >
31
27
</ html >
32
28
) ;
Original file line number Diff line number Diff line change 1
1
import Image from "next/image" ;
2
2
import { Button } from "@/components/ui/button" ;
3
+ import { ModeToggle } from "@/components/custom/mode-toggle" ;
3
4
4
5
export default function Home ( ) {
5
6
return (
@@ -10,6 +11,8 @@ export default function Home() {
10
11
< code className = "font-mono font-bold" > src/app/page.tsx</ code >
11
12
</ p >
12
13
< Button > Click</ Button >
14
+ < ModeToggle />
15
+ test
13
16
< div className = "fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:size-auto lg:bg-none" >
14
17
< a
15
18
className = "pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
Original file line number Diff line number Diff line change
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Moon , Sun } from "lucide-react"
5
+ import { useTheme } from "next-themes"
6
+
7
+ import { Button } from "@/components/ui/button"
8
+ import {
9
+ DropdownMenu ,
10
+ DropdownMenuContent ,
11
+ DropdownMenuItem ,
12
+ DropdownMenuTrigger ,
13
+ } from "@/components/ui/dropdown-menu"
14
+
15
+ export function ModeToggle ( ) {
16
+ const { setTheme } = useTheme ( )
17
+
18
+ return (
19
+ < DropdownMenu >
20
+ < DropdownMenuTrigger asChild >
21
+ < Button variant = "outline" size = "icon" >
22
+ < Sun className = "h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
23
+ < Moon className = "absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
24
+ < span className = "sr-only" > Toggle theme</ span >
25
+ </ Button >
26
+ </ DropdownMenuTrigger >
27
+ < DropdownMenuContent align = "end" >
28
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "light" ) } >
29
+ Light
30
+ </ DropdownMenuItem >
31
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "dark" ) } >
32
+ Dark
33
+ </ DropdownMenuItem >
34
+ < DropdownMenuItem onClick = { ( ) => setTheme ( "system" ) } >
35
+ System
36
+ </ DropdownMenuItem >
37
+ </ DropdownMenuContent >
38
+ </ DropdownMenu >
39
+ )
40
+ }
Original file line number Diff line number Diff line change
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { ThemeProvider as NextThemesProvider } from "next-themes"
5
+ import { type ThemeProviderProps } from "next-themes/dist/types"
6
+
7
+ export function ThemeProvider ( { children, ...props } : ThemeProviderProps ) {
8
+ return < NextThemesProvider { ...props } > { children } </ NextThemesProvider >
9
+ }
You can’t perform that action at this time.
0 commit comments