DEV Community

Discussion on: Extending the theme in Material UI with TypeScript

Collapse
 
codebelt profile image
Robert S. • Edited

Thanks Dude! This was great and it lead me to figure out this solution:

import { createMuiTheme, Theme } from '@material-ui/core/styles';
import createPalette from '@material-ui/core/styles/createPalette';

const theme = {
  typography: {
    secondaryFontFamily: 'Georgia',
  },
};

export type CustomTheme = Theme & typeof theme;

export const myTheme = createMuiTheme(
  {
    palette: createPalette({}),
  },
  theme
) as CustomTheme;

const MyApp: React.FC = () => {
  return (
    <ThemeProvider theme={myTheme}>
      <CssBaseline />
      <SomeComponent />
    </ThemeProvider>
  );
};
Enter fullscreen mode Exit fullscreen mode

Using Material-UI v4.11.1

Collapse
 
fredrikbergqvist profile image
Fredrik Bergqvist

Glad it could help!