1. Material UI
- https://m3.material.io/
- ๊ตฌ๊ธ์ด 2014๋ ์๋๋ก์ด๋ ์ค๋งํธํฐ์ ์ ์ฉํ๋ฉด์ ์๋ ค์ง
- ๊ตฌ๊ธ์ด ์ ๋ํ๋ ๋์์ธ ์์คํ ์ด๋ผ ์ ๋ฐ์ดํธ๊ฐ ์์ฃผ ์ด๋ฃจ์ด์ง๊ณ ์ฒด๊ณ์ ์
- https://mui.com/core/
- ๊ฐ์ข ํ ๋ง๋ค
2. ์์ 1 : ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
1npm install @mui/material @emotion/react @emotion/styled # ๊ธฐ๋ณธ ์ค์น2npm install @mui/icons-material # Icons
2.1 index.html
index.html์ ๋ค์ link ํ๊ทธ ์ถ๊ฐ
1<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />2<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
- ๊ฐ๊ฐ Roboto font, Icons
2.2 App.js
1// Webpack CSS import2// import 'onsenui/css/onsenui.css';3// import 'onsenui/css/onsen-css-components.css';4// import OnesenUIExample from './components/OnsenUI/OnesenUIExample';5// import AntDesignExample from './components/AntDesign/AntDesignExample';6// import 'semantic-ui-css/semantic.min.css';7// import ReactSemanticUIExample from './components/ReactSemanticUI/ReactSemanticUIExample';8// import 'bootstrap/dist/css/bootstrap.min.css';9// import ReactBootstrapExample from './components/ReactBootstrap/ReactBootstrapExample';10import MaterialUIExample from './components/MaterialUI/MaterialUIExample'1112export default function App() {13return (14<>15<MaterialUIExample />16{/* <ReactBootstrapExample /> */}17{/* <ReactSemanticUIExample /> */}18{/* <AntDesignExample /> */}19{/* <OnesenUIExample /> */}20</>21)22}
2.3 ButtonExample
1import Button from '@mui/material/Button'23export default function ButtonExample() {4return <Button variant="contained">Hello World</Button>5}
2.4 MaterialUIExample
1import ButtonExample from './ButtonExample'23export default function MaterialUIExample() {4return (5<div>6<ButtonExample />7</div>8)9}
3. ๊ณต์ ์ฌ์ดํธ CRA ์์
- https://github.com/mui/material-ui/tree/master/examples/create-react-app
- ์ Github๋ฅผ clone(๋ณต์ )ํ๊ฑฐ๋ Zip์ผ๋ก ๋ค์ด๋ฐ์ ๋ง๋ค์ด๋์ ์์ ๋ฅผ ๋ณผ ์ ์๋ค.
- ์๋๋ฉด ๊ณต์ ์ฌ์ดํธ์ ์์ ๋ณ๋ก Code SandBox๊ฐ ์ ๋์ด ์๋ค.
4. ์์ 3 : Grid
1import * as React from 'react'2import { styled } from '@mui/material/styles'3import Box from '@mui/material/Box'4import Paper from '@mui/material/Paper'5import Grid from '@mui/material/Grid'67const Item = styled(Paper)(({ theme }) => ({8backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',9...theme.typography.body2,10padding: theme.spacing(1),11textAlign: 'center',12color: theme.palette.text.secondary,13}))1415export default function BasicGrid() {16return (17<Box sx={{ flexGrow: 1 }}>18<Grid container spacing={2}>19<Grid item xs={8}>20<Item>xs=8</Item>21</Grid>22<Grid item xs={4}>23<Item>xs=4</Item>24</Grid>25<Grid item xs={4}>26<Item>xs=4</Item>27</Grid>28<Grid item xs={8}>29<Item>xs=8</Item>30</Grid>31</Grid>32</Box>33)34}
MaterialUIExample์ ์ถ๊ฐ