mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
44 lines
868 B
TypeScript
44 lines
868 B
TypeScript
"use client"
|
|
|
|
import { Moon, Sun } from "lucide-react"
|
|
import { useTheme } from "next-themes"
|
|
import { useEffect, useState } from "react"
|
|
|
|
export const ThemeToggle = () => {
|
|
const { theme, setTheme } = useTheme()
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
// Ensure component is mounted to avoid hydration mismatch
|
|
useEffect(() => {
|
|
setMounted(true)
|
|
}, [])
|
|
|
|
if (!mounted) {
|
|
return null
|
|
}
|
|
|
|
const toggleTheme = () => {
|
|
if (theme === "dark") {
|
|
setTheme("light")
|
|
} else {
|
|
setTheme("dark")
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div onClick={toggleTheme} className="flex items-center gap-2 cursor-pointer">
|
|
{theme === "dark" ? (
|
|
<>
|
|
<Sun className="h-4 w-4" />
|
|
Light Mode
|
|
</>
|
|
) : (
|
|
<>
|
|
<Moon className="h-4 w-4" />
|
|
Dark Mode
|
|
</>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|