Spaces:
Configuration error
Configuration error
File size: 809 Bytes
74aacd5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import React, { useEffect } from 'react'
import { atom, useRecoilState } from 'recoil'
import { SunIcon, MoonIcon } from '@heroicons/react/24/outline'
export const themeState = atom({
key: 'themeState',
default: 'dark',
})
export const ThemeChanger = () => {
const [theme, setTheme] = useRecoilState(themeState)
const themeSwitchHandler = () => {
const newTheme = theme === 'light' ? 'dark' : 'light'
setTheme(newTheme)
}
return (
<div className="theme-toggle-ui">
<div
className="theme-btn"
onClick={themeSwitchHandler}
role="button"
tabIndex={0}
aria-hidden="true"
>
{theme === 'light' ? (
<MoonIcon />
) : (
<SunIcon style={{ color: '#ffcc00' }} />
)}
</div>
</div>
)
}
|