UNPKG

leumas-universal-crud-react

Version:

Leumas Universal CRUD to a dynamic Endpoint, Setup your own Dynamic Endpoint and Use Leumas API to send to your MONGO clusters

48 lines (44 loc) 1.47 kB
import { FaMoon, FaSun } from 'react-icons/fa'; // Import icons for light and dark themes import { useTheme } from './ThemeContext'; // Adjust the import path as necessary const ThemeToggleButton = () => { const { theme, toggleTheme } = useTheme(); return ( <button onClick={toggleTheme} className="bg-transparent border-none cursor-pointer p-2 rounded-full transition duration-500 ease-in-out transform hover:scale-110 focus:outline-none" style={{ position: 'relative', display: 'inline-block', width: '50px', height: '50px' }} > <div className="absolute" style={{ transition: 'opacity 500ms ease-in-out', opacity: theme === 'light' ? 1 : 0, position: 'absolute', inset: 0, display: 'flex', justifyContent: 'center', alignItems: 'center', }} > <FaMoon className="text-xl text-blue-500" /> </div> <div className="absolute" style={{ transition: 'opacity 500ms ease-in-out', opacity: theme === 'dark' ? 1 : 0, position: 'absolute', inset: 0, display: 'flex', justifyContent: 'center', alignItems: 'center', }} > <FaSun className="text-xl text-blue-300" /> </div> </button> ); }; export default ThemeToggleButton;