Files
cronmaster/app/_components/FeatureComponents/Theme/ThemeToggle.tsx
2025-12-31 20:09:11 +00:00

27 lines
567 B
TypeScript

'use client'
import { useTheme } from 'next-themes';
import { useEffect, useState } from 'react';
export const ThemeToggle = () => {
const [mounted, setMounted] = useState(false);
const { theme, setTheme } = useTheme();
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) return null;
const isDark = theme === 'dark';
return (
<button
onClick={() => setTheme(isDark ? 'light' : 'dark')}
className="px-3 py-2 ascii-border terminal-font text-sm bg-background0"
>
{isDark ? 'LIGHT' : 'DARK'}
</button>
);
};