Last active
May 20, 2021 03:10
-
-
Save IsaiahByDayah/2abe7175d02ab06ee669f03da0f7a52e to your computer and use it in GitHub Desktop.
MUI Theme with Custom Colors
This file contains hidden or 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
// REF: https://material-ui.com/customization/palette/#adding-new-colors | |
import { FC } from "react" | |
import { | |
ThemeProvider as MuiThemeProvider, | |
createMuiTheme, | |
responsiveFontSizes, | |
} from "@material-ui/core" | |
// include these here so the compiler can add the types | |
declare module "@material-ui/core/styles/createMuiTheme" { | |
interface Theme { | |
status: { | |
danger: React.CSSProperties["color"] | |
} | |
} | |
interface ThemeOptions { | |
status: { | |
danger: React.CSSProperties["color"] | |
} | |
} | |
} | |
declare module "@material-ui/core/styles/createPalette" { | |
interface Palette { | |
neutral: Palette["primary"] | |
} | |
interface PaletteOptions { | |
neutral: PaletteOptions["primary"] | |
} | |
} | |
const ThemeProvider: FC = ({ children }) => { | |
const theme = responsiveFontSizes( | |
createMuiTheme({ | |
// Custom color outside of palette | |
status: { | |
danger: "#e53e3e", | |
}, | |
palette: { | |
primary: { | |
main: "#006d77", | |
contrastText: "#FFFFFF", | |
}, | |
// Custom color under palette | |
neutral: { | |
main: "#bf1313", | |
}, | |
}, | |
}) | |
) | |
return <MuiThemeProvider theme={theme}>{children}</MuiThemeProvider> | |
} | |
export default ThemeProvider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment