Created
December 4, 2021 19:32
-
-
Save Momotoculteur/7c0205bd81e6f372e12c467dc5e55d24 to your computer and use it in GitHub Desktop.
custom dark light theme switch system for react app build with material ui design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Stack from '@material-ui/core/Stack'; | |
import Button from '@material-ui/core/Button'; | |
import { Switch, Typography } from '@material-ui/core'; | |
import { Box } from '@material-ui/system'; | |
import { useContext } from 'react'; | |
import ThemeContext from '../Theme/ThemeContext'; | |
function ContentApp() { | |
const { isDark, toggleTheme } = useContext(ThemeContext); | |
return ( | |
<Box> | |
<Stack spacing={2} direction="row"> | |
<Button variant="text">Text</Button> | |
<Button variant="contained" onClick={toggleTheme}>Change Theme button</Button> | |
<Button variant="outlined">Outlined</Button> | |
</Stack> | |
<Typography> | |
<Switch checked={isDark} onChange={toggleTheme} /> | |
Change Theme switch | |
</Typography> | |
</Box> | |
) | |
} | |
export default ContentApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment