๊ธฐ๋ณธ ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์ค๋ช ์ ๋๋ค. ๐ฅ
https://avoc-o-d.tistory.com/43
[Material Design] Material-UI(MUI)๋ก react & styled component ์ฌ์ฉํ๊ธฐ <๊ธฐ๋ณธ ์ปดํฌ๋ํธ ์ฌ์ฉํ๊ธฐ>
https://mui.com/material-ui/getting-started/overview/ ์ปดํฌ๋ํธ๋ค์ ์ผ์ชฝ ์ฌ์ด๋๋ฐ์์ Components์ ์์ต๋๋ค. ๐ 00. ์ปดํฌ๋ํธ ์ฌ์ฉํ๊ธฐ ์๋ฅผ ๋ค์ด, ๋ฒํผ์ ์ฌ์ฉํ๊ณ ์ถ์ ๋ Button ์ผ๋ก ๋ค์ด๊ฐ๋๋ค. https..
avoc-o-d.tistory.com
00. Styled Component
styled ํ ์ปดํฌ๋ํธ๋ฅผ import ํฉ๋๋ค. (์ ๋ ์๋ฅผ ๋ค์ด ๋ฒํผ์ import ํ๊ฒ ์ต๋๋ค!)
๊ทธ๋ฆฌ๊ณ styled๋ฅผ ํ๊ธฐ ์ํด, styled๋ฅผ import ํฉ๋๋ค.
import { styled } from "@mui/material/styles";
๊ธฐ์กด ๋ฉํ ๋ฆฌ์ผ ๋์์ธ 2๊ฐ ์ ํ Button ์ ๋๋ค.
import "./styles.css";
import React from "react";
import Button from "@mui/material/Button";
export default function App() {
return (
<div className="App">
<Button variant="contained">๋ก๊ทธ์ธ</Button>
</div>
);
}
์ฌ์ฉ์๊ฐ styled๋ฅผ ์ ์ํ Button์ ๋๋ค.
import "./styles.css";
import React from "react";
import { styled } from "@mui/material/styles";
import Button from "@mui/material/Button";
const MyButton = styled(Button)`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
font-family: "Noto Sans KR";
`;
export default function App() {
return (
<div className="App">
<MyButton variant="contained">๋ก๊ทธ์ธ</MyButton>
</div>
);
}
01. sx parameter (MUI ๊ฐ์ด๋)
mui ๊ฐ์ด๋์ ๋์จ ๊ฒ์ฒ๋ผ sx ์ธ์๋ฅผ ๋ณด๋ด์ ์ปค์คํฐ๋ง์ด์ง ๊ฐ๋ฅํฉ๋๋ค.
import "./styles.css";
import React from "react";
import Button from "@mui/material/Button";
export default function App() {
return (
<div className="App">
<Button variant="contained" sx={{ height: 100 }}>๋ก๊ทธ์ธ</Button>
</div>
);
}
์ด๊ฒ๋ ๋น์ฐํ ๊ฐ๋ฅํฉ๋๋ค!
import "./styles.css";
import React from "react";
import { styled } from "@mui/material/styles";
import Button from "@mui/material/Button";
const MyButton = styled(Button)`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
font-family: "Noto Sans KR";
`;
export default function App() {
return (
<div className="App">
<MyButton variant="contained" sx={{ height: 100 }}>
๋ก๊ทธ์ธ
</MyButton>
</div>
);
}
๐ ํ์ฌ๋ ๊ธฐ๋ณธ๊ฐ์ธ theme์์ styled๋ฅผ ํ์ฌ ์ฌ์ฉํ์ง๋ง, ๋ค์์ theme๋ฅผ ์ปค์คํฐ๋ง์ด์ง ํ๋ ๋ฒ์ ๋ํด ๊ธฐ์ ํ ์์ ์ ๋๋ค.