๐ค ์์งlog ๐ค
[REACT] SCSS ๋ณธ๋ฌธ
SCSS
sass๋ css์ ๋น์ทํ๊ฒ App.scss ํ์ผ์ ๋ง๋ค์ด scss ๋ฌธ๋ฒ์ ๋ง๊ฒ ์ฝ๋ ๋ฃ๋๊ฒ ์ด๋ค.
Sass๋ ๋๊ฐ์ง ํ์ฅ์(.scss/.sass)๋ฅผ ์ง์ํ๊ณ ๐ npm install ์์ ์ด ํ์ํจ. ( node- sass ) ๐
import styled, { css } from 'styled-components'
const Box = styled.div`
background: ${(props) => props.color || 'blue'};
padding: 1rem;
display: flex;
`
//Box ์ปดํฌ๋ํธ์ .color ๋ผ๋ props๊ฐ ์์ผ๋ฉด blue๊ฐ ๋๋ค-> ์ง๊ธ์ ์์ผ๋ black
const Button = styled.button`
background: white;
color: black;
border-radius: 4px;
padding: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: 1rem;
font-weight: 600;
&:hover {
background: rgba(255, 255, 255, 0.9);
}
${(props) =>
props.inverted &&
/* inverted๊ฐ์ด true๋ฉด ๋ฐ ์์ฑ๋ค์ด ์ ์ฉ๋๋ค */
css`
background: none;
border: 2px solid white;
color: white;
&:hover {
background: white;
color: black;
}
`}
&+button {
margin-left: 1rem;
}
`
const StyledComponent = () => (
<Box color="black">
<Button>์๋
ํ์ธ์</Button>
<Button inverted={true}>ํ
๋๋ฆฌ๋ง</Button>
</Box>
)
export default StyledComponent
728x90
'๐ React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[REACT] ๋ฐ๋ณต ( Iteration ) (0) | 2022.10.07 |
---|---|
[REACT] HOOK (0) | 2022.10.07 |
[REACT] SPA ์ async (0) | 2022.10.06 |
[REACT] useEffect๊ฐ 2๋ฒ์คํ๋ ๋ (0) | 2022.10.06 |
[REACT] To-do List ๋ง๋ค๊ธฐ (0) | 2022.10.06 |