mirror of
https://github.com/fccview/cronmaster.git
synced 2026-02-01 09:32:04 -05:00
27 lines
567 B
TypeScript
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>
|
|
);
|
|
};
|