mirror of
https://github.com/harivansh-afk/React-Portfolio.git
synced 2026-04-15 05:02:11 +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 [theme, settheme] = useState(localStorage.getItem("theme"));
|
||||
const [theme, settheme] = useState(localStorage.getItem("theme") || "dark");
|
||||
const themetoggle = () => {
|
||||
settheme(theme === "dark" ? "light" : "dark");
|
||||
};
|
||||
useEffect(() => {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('theme', theme );
|
||||
localStorage.setItem('theme', theme );
|
||||
}, [theme]);
|
||||
return (
|
||||
<div className="nav_ac" onClick={themetoggle}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue