Skip to content

Instantly share code, notes, and snippets.

@amitsinghrawat1994
Last active January 30, 2022 11:20
Show Gist options
  • Select an option

  • Save amitsinghrawat1994/31bd296ae051bf9729431712d79d02fd to your computer and use it in GitHub Desktop.

Select an option

Save amitsinghrawat1994/31bd296ae051bf9729431712d79d02fd to your computer and use it in GitHub Desktop.
Add a custom variable in Material UI version 4
// add a custom variable in Material ui
// ref: https://github.com/mui-org/material-ui/issues/13802#issuecomment-444200131
import createMuiTheme from "@material-ui/core/styles/createMuiTheme";
import { PaletteColor, PaletteColorOptions } from "@material-ui/core/styles/createPalette";
declare module "@material-ui/core/styles/createPalette" {
interface Palette {
blue: PaletteColor;
}
interface PaletteOptions {
blue: PaletteColorOptions;
}
}
export default createMuiTheme({
palette: {
blue: {
main: "blue"
}
}
});
// Add CommonColors
// Ref: https://stackoverflow.com/a/68433584
import "@mui/material/styles/createPalette";
declare module "@mui/material/styles/createPalette" {
interface CommonColors {
tan: string;
lightRed: string;
red: string;
offBlack: string;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment