React - CSS FrameWork ㅡ MUI 사용하기
#0. MUi 는 처음 써보는데 문서정리가 잘되있어서 빠르게 배울수 있다는 느낌을 받았다. 그래서 조금씩 알아가기로 함.
#1. 예제 1
import React, { useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import NoSsr from "@material-ui/core/NoSsr";
import { Button, Container, Typography } from "@material-ui/core/";
import { makeStyles, createMuiTheme } from "@material-ui/core/styles";
import { palette, spacing, typography } from "@material-ui/system";
import BottomNavigation from "@material-ui/core/BottomNavigation";
import BottomNavigationAction from "@material-ui/core/BottomNavigationAction";
import RestoreIcon from "@material-ui/icons/Restore";
import FavoriteIcon from "@material-ui/icons/Favorite";
import LocationOnIcon from "@material-ui/icons/LocationOn";
const theme = createMuiTheme();
const useStyles = makeStyles({
root: {
width: 500
}
});
const Box = styled.div`${palette}${spacing}${typography}`;
export default function App() {
const classes = useStyles();
const [value, setValue] = useState(0);
return (
<ThemeProvider theme={theme}>
<Container maxWidth="sm">
{value === 0 && (
<NoSsr>
<Box
style={{ backgroundColor: "#cfe8fc", height: "80vh" }}
color="primary.main"
fontFamily="h6.fontFamily"
fontSize={{
xs: "h6.fontSize",
sm: "h4.fontSize",
md: "h3.fontSize"
}}
p={{ xs: 2, sm: 3, md: 4 }}
>
<div>@material-ui/system</div>
<Button variant="contained" color="primary">
Hello World
</Button>
</Box>
</NoSsr>
)}
{value === 1 && (
<NoSsr>
<Box
style={{ backgroundColor: "#cfe8fc", height: "80vh" }}
color="primary.main"
fontFamily="h6.fontFamily"
fontSize={{
xs: "h6.fontSize",
sm: "h4.fontSize",
md: "h3.fontSize"
}}
p={{ xs: 2, sm: 3, md: 4 }}
>
<div>제가 좋아하는 CSS 프레임 워크이죠</div>
<Button variant="contained" color="primary">
두배로 빨리 배우기
</Button>
</Box>
</NoSsr>
)}
{value === 2 && (
<NoSsr>
<Box
style={{ backgroundColor: "#cfe8fc", height: "80vh" }}
color="primary.main"
fontFamily="h6.fontFamily"
fontSize={{
xs: "h6.fontSize",
sm: "h4.fontSize",
md: "h3.fontSize"
}}
p={{ xs: 2, sm: 3, md: 4 }}
>
<div>허리가 아픈가요?</div>
<Button variant="contained" color="primary">
곱게 피세요
</Button>
</Box>
</NoSsr>
)}
<BottomNavigation
value={value}
onChange={(event, newValue) => {
setValue(newValue);
}}
showLabels
className={classes.root}
>
<BottomNavigationAction label="Recents" icon={<RestoreIcon />} />
<BottomNavigationAction label="Favorites" icon={<FavoriteIcon />} />
<BottomNavigationAction label="Nearby" icon={<LocationOnIcon />} />
</BottomNavigation>
</Container>
</ThemeProvider>
);
}
DOS IMPACT - WEB Developer
KIM DO YOUNG
WEB : REACT JS | REACT NATIVE | GraphQL PRISMA
'React JS > Lecture' 카테고리의 다른 글
React 리액트 - 이모티콘 사용법 알아보기 react-icons-kit (0) | 2020.02.10 |
---|---|
React - React - Hook 리액트 훅 사용법 정리 (3) useInput, useFetch (0) | 2020.02.03 |
React - Tab컴포넌트 사용해 보기 (0) | 2020.02.03 |
React - 아이콘 icon 사용하기 - react-icons-kit (0) | 2020.02.03 |
React - styled-media-query 미디어 쿼리 사용법 (0) | 2020.02.03 |