Material UI

Overview

  • Open-source React component library that implements Google's Material Design

  • Material UI is comprehensive in that it comes packaged with default styles, and is optimized to work with Emotion which allows writing css in js

Customization

Theme Provider

  • ThemeProvider relies on the context feature of React to pass the theme down to the components and override the default palette, font size, ...

defaultTheme.ts
import { createTheme } from "@mui/material";
import { purple } from "@mui/material/colors";
const theme = createTheme({
   palette:{
    primary:purple,
   },
   typography: {
    fontFamily: "sans-serif",
    fontSize: 12,
    h3 : {
        fontSize: '1.2rem',
        '@media (min-width:600px)': {
            fontSize: '1.5rem',
        },
    }
  },
  breakpoints: {
    values: {
      xs: 0,
      sm: 600,
      md: 900,
      lg: 1200,
      xl: 1536,
    },
  },
})

export default theme;
  • The theme can also be accessed by using hook

Styled Function

Inline props

Last updated

Was this helpful?