You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
610 B
31 lines
610 B
import { FC, useEffect, useState } from "react";
|
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
import styles from "./themeChanger.module.scss";
|
|
|
|
const ThemeChanger: FC = () => {
|
|
const [mounted, setMounted] = useState(false);
|
|
const { theme, setTheme } = useTheme();
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) return <></>;
|
|
|
|
return (
|
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
<a
|
|
role="button"
|
|
tabIndex={0}
|
|
className={styles.main}
|
|
onClick={() => setTheme(theme == "light" ? "dark" : "light")}
|
|
>
|
|
{theme}
|
|
</a>
|
|
);
|
|
};
|
|
|
|
export default ThemeChanger;
|