mirror of
https://github.com/harivansh-afk/React-Portfolio.git
synced 2026-04-21 06:04:47 +00:00
chore: dark mode default
This commit is contained in:
parent
fb5b992b17
commit
6d17375685
1 changed files with 2 additions and 2 deletions
|
|
@ -3,13 +3,13 @@ import { WiMoonAltWaningCrescent4 } from "react-icons/wi";
|
||||||
|
|
||||||
|
|
||||||
const Themetoggle = () => {
|
const Themetoggle = () => {
|
||||||
const [theme, settheme] = useState(localStorage.getItem("theme"));
|
const [theme, settheme] = useState(localStorage.getItem("theme") || "dark");
|
||||||
const themetoggle = () => {
|
const themetoggle = () => {
|
||||||
settheme(theme === "dark" ? "light" : "dark");
|
settheme(theme === "dark" ? "light" : "dark");
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.documentElement.setAttribute('data-theme', theme);
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
localStorage.setItem('theme', theme );
|
localStorage.setItem('theme', theme );
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
return (
|
return (
|
||||||
<div className="nav_ac" onClick={themetoggle}>
|
<div className="nav_ac" onClick={themetoggle}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue