Customize MUI
Published: 2021-09-28 18:20:18

[Material-UI](https://mui.com/), recently rebranded to simply "MUI", is a powerful library of styled components that can quickly bootstrap a React application to look uniform, clean, and professional. The reasons for MUI's popularity are clear; it is easy to learn and use. Users can get an app quickly styled and save many a CSS-induced headache. However, some criticize MUI for being limitably customizable. This blog will show how to easily override MUI's default styles to give your application the look you want. 

### How does MUI styling work? 

Before learning how to customize our React app, it’s important to get a basic sense of how the MUI standard theme works. Think of MUI's main theme like a giant object that specifies styling for all instances of MUI components. In this object, the default styles are defined for each of MUI's unique components. For example, Typography components will have be rendered with the Roboto font family:

![Typography example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2drgwudknzvosvzynudi.png)

Any Button component will be rendered in all caps and have a ripple effect on click:

![Button example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ouhnfacxbs6lh78zm01.gif)

And any component involving color will make use of MUI's default color palette. The classic main blue, deep purple, and error red:

![MUI palette](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhpbhq8vd4wuaxm2xgee.png)

A reasonable first step to customization would be to familiarize yourself with MUI’s [default theme object](https://mui.com/customization/default-theme/) and begin playing with properties in a sandbox. 

### Demo

#### 1. Import React ThemeProvider

*For the purposes of this demo, we will be customizing your app's themes globally, by wrapping our entire app with a MUI ThemeProvider. If you wish to customize only certain components, you can wrap specific components with the ThemeProvider  or browse MUI's [documentation](https://mui.com/customization/how-to-customize/) for other ways to customize more granularly.*

First, import ThemeProvider and createTheme from MUI. Then, define your theme to override MUI's built-in theme object.
As always, check on the mui website that you have the latest version installed and are importing your MUI elements correctly at the top of your React.js files.


![import ThemeProvider](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xsb9fedkjmc0bxb8vyxw.png)

#### 2. Define your color palette

It's finally time to leave that classic MUI blue behind and create your own color palette, perhaps using a palette generator tool [like ColorSpace](https://mycolor.space/). For learning purposes, let's go with an Iron Man palette. 

 ![Iron Man palette](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjt8iy07v4ctb4f45nrc.png)

Define your palette's colors. For our purposes, we will simply define "main" and "dark" shades for our theme's primary and secondary colors. 


![color palette](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mz5qb5cbm4w2lxbd6d5g.png)


#### 3. Define your typography. 

An easy way to find a font that works for you is to Browse [Google fonts](https://fonts.google.com/) and import directly into your index.css file in your app. From there, you can reference the font by its family name. 

![import fonts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ledglrbfolpasgzuee21.png)

After implementing our fonts, we can transform a basic login page from MUI's standard look...

![login standard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obcqizm2wi9gyup3x1vs.png)

...to something worthy of Tony Stark...

![login Iron Man](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zamdpl7y4ldn1er6lzy.png)

### Keep going!

There are many ways to give your app it's own identity and *feel*, from buttons to headers to menubars and animation effects. Take that ThemeProvider and fly with it.