Skip to content

Instantly share code, notes, and snippets.

@tr00st
Created March 11, 2020 10:18
Show Gist options
  • Save tr00st/da2abc576fe38ed3eed266340465830e to your computer and use it in GitHub Desktop.
Save tr00st/da2abc576fe38ed3eed266340465830e to your computer and use it in GitHub Desktop.
Horrendous Material-UI theme generator
import { createMuiTheme } from "@material-ui/core";
/*
Generates a random theme for Material-UI. Usually horrible.
*/
const randomColor = () => {
return ["#",Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16),Math.floor((Math.random()*16)).toString(16)].join("");
}
const theme = createMuiTheme({
palette: {
type: Math.random() > 0.5 ? 'dark' : "light",
primary: {
main: randomColor()
},
secondary: {
main: randomColor()
},
background: {
default: randomColor(),
paper: randomColor()
}
}
});
// Log the palette in case it's horrendous enough that you want to keep it
console.log(theme.palette);
export default theme;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment