mirror of
https://github.com/R0m1k3/Menu.git
synced 2026-10-14 18:56:20 +02:00
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import { Moon, Sun } from 'lucide-react';
|
|
import { useTheme } from 'next-themes';
|
|
|
|
export function ThemeToggle() {
|
|
const { theme, setTheme } = useTheme();
|
|
const [mounted, setMounted] = React.useState(false);
|
|
|
|
React.useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) {
|
|
return <div style={{ width: '40px', height: '40px' }} />;
|
|
}
|
|
|
|
return (
|
|
<button
|
|
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
|
|
aria-label="Basculer le thème"
|
|
style={{
|
|
background: 'var(--glass-bg)',
|
|
backdropFilter: 'blur(20px)',
|
|
WebkitBackdropFilter: 'blur(20px)',
|
|
border: '1px solid var(--glass-border)',
|
|
boxShadow: 'var(--glass-shadow)',
|
|
borderRadius: '50%',
|
|
width: '40px',
|
|
height: '40px',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
cursor: 'pointer',
|
|
flexShrink: 0,
|
|
}}
|
|
>
|
|
{theme === 'dark'
|
|
? <Sun size={18} color="var(--fg)" />
|
|
: <Moon size={18} color="var(--fg)" />
|
|
}
|
|
</button>
|
|
);
|
|
}
|