Spaces:
Sleeping
Sleeping
File size: 919 Bytes
532554f af68ace 532554f af68ace 532554f af68ace 532554f 10283cc 532554f 10283cc 532554f 10283cc af68ace 10283cc 532554f 10283cc 532554f 10283cc 532554f af68ace | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 'use client';
import { Moon, Sun } from 'lucide-react';
import { useTheme } from 'next-themes';
import * as React from 'react';
import { Button } from '@/components/ui/button';
export function ThemeToggle() {
const { setTheme, theme } = useTheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return <Button variant="ghost" size="icon" className="h-7 w-7" disabled />;
}
return (
<Button
variant="ghost"
size="icon"
className="h-7 w-7"
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
>
<Sun className="h-3.5 w-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
<Moon className="absolute h-3.5 w-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
<span className="sr-only">Toggle theme</span>
</Button>
);
}
|