mirror of
https://github.com/mroxso/zelo-news.git
synced 2026-04-10 23:47:11 +02:00
28 lines
619 B
TypeScript
28 lines
619 B
TypeScript
import { Moon, Sun } from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
import { useTheme } from '@/hooks/useTheme';
|
|
|
|
export function ThemeToggle() {
|
|
const { theme, setTheme } = useTheme();
|
|
|
|
const toggleTheme = () => {
|
|
setTheme(theme === 'light' ? 'dark' : 'light');
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={toggleTheme}
|
|
className="h-9 w-9"
|
|
>
|
|
{theme === 'light' ? (
|
|
<Moon className="h-4 w-4" />
|
|
) : (
|
|
<Sun className="h-4 w-4" />
|
|
)}
|
|
<span className="sr-only">Toggle theme</span>
|
|
</Button>
|
|
);
|
|
}
|