mirror of
https://github.com/R0m1k3/Menu.git
synced 2026-10-11 17:28:28 +02:00
41 lines
1.1 KiB
TypeScript
41 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: '38px', height: '38px' }} />;
|
|
|
|
return (
|
|
<button
|
|
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
|
|
aria-label="Basculer le thème"
|
|
style={{
|
|
background: 'rgba(255,255,255,0.12)',
|
|
backdropFilter: 'blur(16px)',
|
|
WebkitBackdropFilter: 'blur(16px)',
|
|
border: '1px solid rgba(255,255,255,0.18)',
|
|
borderRadius: '50%',
|
|
width: '38px',
|
|
height: '38px',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
cursor: 'pointer',
|
|
transition: 'background 260ms ease',
|
|
}}
|
|
>
|
|
{theme === 'dark'
|
|
? <Sun size={15} color="rgba(255,255,255,0.85)" />
|
|
: <Moon size={15} color="rgba(255,255,255,0.85)" />
|
|
}
|
|
</button>
|
|
);
|
|
}
|