Installation
Install Material UI, the world's most popular React UI framework.
Default installation
Run one of the following commands to add Material UI to your project:
npm
npm install @mui/material @emotion/react @emotion/styled
yarn
yarn add @mui/material @emotion/react @emotion/styled
With styled-components
Material UI uses Emotion as its default styling engine. If you want to use styled-components instead, run one of the following commands:
npm
npm install @mui/material @mui/styled-engine-sc styled-components
yarn
yarn add @mui/material @mui/styled-engine-sc styled-components
Peer dependencies
Please note that react and react-dom are peer dependencies too:
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
Roboto font
Material UI is designed to use the Roboto font by default. You may add it to your project with npm or yarn via Fontsource, or with the Google Fonts CDN.
npm
npm install @fontsource/roboto
yarn
yarn add @fontsource/roboto
Then you can import it in your entry point like this:
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
Google Web Fonts
To install the Roboto font in your project using the Google Web Fonts CDN, add the following code snippet inside your project's <head />
tag:
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
Icons
To use the font Icon component or the prebuilt SVG Material Icons (such as those found in the icon demos), you must first install the Material Icons font. You can do so with npm or yarn, or with the Google Web Fonts CDN.
npm
npm install @mui/icons-material
yarn
yarn add @mui/icons-material
Google Web Fonts
To install the Material Icons font in your project using the Google Web Fonts CDN, add the following code snippet inside your project's <head />
tag:
To use the font Icon
component, you must first add the Material Icons font.
Here are some instructions
on how to do so.
For instance, via Google Web Fonts:
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
CDN
You can start using Material UI right away with minimal front-end infrastructure by installing it via CDN, which is a great option for rapid prototyping. Follow this CDN example to get started.
Two Universal Module Definition (UMD) files are provided:
- one for development: https://unpkg.com/@mui/material@latest/umd/material-ui.development.js
- one for production: https://unpkg.com/@mui/material@latest/umd/material-ui.production.min.js