Skip to content

Instantly share code, notes, and snippets.

@uds5501
Created May 6, 2020 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uds5501/a6ecaaff87d0a71d35fdef6367eb1d30 to your computer and use it in GitHub Desktop.
Save uds5501/a6ecaaff87d0a71d35fdef6367eb1d30 to your computer and use it in GitHub Desktop.
adding new colours in the mix
import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles";
import React, { useState } from "react";
import Switch from "@material-ui/core/Switch";
export default function Dashboard() {
const [darkState, setDarkState] = useState(false);
const palletType = darkState ? "dark" : "light";
const mainPrimaryColor = darkState ? orange[500] : lightBlue[500];
const mainSecondaryColor = darkState ? deepOrange[900] : deepPurple[500];
const darkTheme = createMuiTheme({
palette: {
type: palletType,
primary: {
main: mainPrimaryColor
},
secondary: {
main: mainSecondaryColor
}
}
});
const handleThemeChange = () => {
setDarkState(!darkState);
};
return (
<ThemeProvider theme={darkTheme}>
<div> Sample Text </div>
<Switch checked={darkState} onChange={handleThemeChange} />
</ThemeProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment