mirror of
https://github.com/siteboon/claudecodeui.git
synced 2025-12-13 13:49:43 +00:00
35 lines
1.6 KiB
JavaScript
35 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import { useTheme } from '../contexts/ThemeContext';
|
|
|
|
function DarkModeToggle() {
|
|
const { isDarkMode, toggleDarkMode } = useTheme();
|
|
|
|
return (
|
|
<button
|
|
onClick={toggleDarkMode}
|
|
className="relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900"
|
|
role="switch"
|
|
aria-checked={isDarkMode}
|
|
aria-label="Toggle dark mode"
|
|
>
|
|
<span className="sr-only">Toggle dark mode</span>
|
|
<span
|
|
className={`${
|
|
isDarkMode ? 'translate-x-7' : 'translate-x-1'
|
|
} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`}
|
|
>
|
|
{isDarkMode ? (
|
|
<svg className="w-3.5 h-3.5 text-gray-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
|
|
</svg>
|
|
) : (
|
|
<svg className="w-3.5 h-3.5 text-yellow-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
|
|
</svg>
|
|
)}
|
|
</span>
|
|
</button>
|
|
);
|
|
}
|
|
|
|
export default DarkModeToggle; |