Commit cacea21 1 parent 4ec587c commit cacea21 Copy full SHA for cacea21
File tree 1 file changed +34
-0
lines changed
services/explorer-ui/src/components
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { MoonIcon , SunIcon } from "lucide-react" ;
2
+ import { useTheme as useNextTheme } from "next-themes" ;
3
+ import { Button } from "./ui/button" ;
4
+ import { useEffect , useState } from "react" ;
5
+
6
+ export function ThemeToggle ( ) {
7
+ const { theme, setTheme } = useNextTheme ( ) ;
8
+ const [ mounted , setMounted ] = useState ( false ) ;
9
+
10
+ // Avoid hydration mismatch by only rendering after mount
11
+ useEffect ( ( ) => {
12
+ setMounted ( true ) ;
13
+ } , [ ] ) ;
14
+
15
+ if ( ! mounted ) {
16
+ return < Button variant = "ghost" size = "icon" className = "w-9 px-0" /> ;
17
+ }
18
+
19
+ return (
20
+ < Button
21
+ variant = "ghost"
22
+ size = "icon"
23
+ className = "w-9 px-0 text-white hover:text-white hover:bg-purple-light/20"
24
+ onClick = { ( ) => setTheme ( theme === "dark" ? "light" : "dark" ) }
25
+ aria-label = "Toggle theme"
26
+ >
27
+ { theme === "dark" ? (
28
+ < SunIcon className = "h-5 w-5" />
29
+ ) : (
30
+ < MoonIcon className = "h-5 w-5" />
31
+ ) }
32
+ </ Button >
33
+ ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments