Theme toggle

This commit is contained in:
2025-02-21 12:02:04 +01:00
parent 030488a451
commit 2bae543492
2 changed files with 40 additions and 57 deletions
+27
View File
@@ -0,0 +1,27 @@
'use client';
import { useTheme } from 'next-themes';
import { useEffect } from 'react';
import { Button } from './ui/button';
import { Lightbulb } from 'lucide-react';
export default function ThemeToggle(
props: React.DetailedHTMLProps<
React.HTMLAttributes<HTMLSpanElement>,
HTMLSpanElement
>
) {
const { setTheme, theme } = useTheme();
return (
<span {...props}>
<Button
className="p-3"
variant="ghost"
onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}
>
<Lightbulb />
</Button>
</span>
);
}