ThemeToggle.tsx (473B)
1 import { useThemeStore } from "../../store/theme"; 2 3 export function ThemeToggle() { 4 const { theme, toggleTheme } = useThemeStore(); 5 const isDark = theme === "dark"; 6 7 return ( 8 <button 9 type="button" 10 onClick={toggleTheme} 11 aria-label={`Switch to ${isDark ? "light" : "dark"} theme`} 12 className="rounded-lg bg-gray-800 px-3 py-1.5 text-sm text-gray-300 hover:bg-gray-700" 13 > 14 {isDark ? "☀️ Light" : "🌙 Dark"} 15 </button> 16 ); 17 }