-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPage 1.jsx
More file actions
44 lines (40 loc) · 1.07 KB
/
Page 1.jsx
File metadata and controls
44 lines (40 loc) · 1.07 KB
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
37
38
39
40
41
42
43
44
import { useContext } from "react";
import { ColorModeContext } from "../../theme";
import { IconButton, useTheme } from "@mui/material";
import { DarkModeOutlined, LightModeOutlined } from "@mui/icons-material";
const Home = () => {
const colorMode = useContext(ColorModeContext);
const theme = useTheme();
return (
<div>
{theme.palette.mode === "light" ? (
<IconButton
onClick={() => {
localStorage.setItem(
"mode",
theme.palette.mode === "dark" ? "light" : "dark"
);
colorMode.toggleColorMode();
}}
color="inherit"
>
<LightModeOutlinedIcon />
</IconButton>
) : (
<IconButton
onClick={() => {
localStorage.setItem(
"mode",
theme.palette.mode === "dark" ? "light" : "dark"
);
colorMode.toggleColorMode();
}}
color="inherit"
>
<DarkModeOutlinedIcon />
</IconButton>
)}
</div>
);
};
export default Home;