728x90
๐ styled-component์์ ํ๊ทธ๊ฐ ๋ค๋ฅด์ง๋ง css๋ ๋์ผํ ๋ css๋ฅผ ๋ณ์๋ก ๊ด๋ฆฌํ๊ธฐ
styled-component
๋ก ํ๊ทธ๋ฅผ ๊พธ๋ฏธ๋ ์ค ํ๊ทธ๋ ๋ค๋ฅด์ง๋ง ๋๋จธ์ง ์คํ์ผ์ ๋์ผํ๊ฒ ์ค์ ํ๋ ๊ฒฝ์ฐ๊ฐ ์์๋ค. ๊ทธ๋ฅ ์คํ์ผ์ ์ค๋ณตํด์ ์ฌ์ฉํด๋ ๋์ง๋ง ๊ทธ๊ฒ๋ณด๋ค ๋์ผํ css
๋ฅผ ๋ณ์๋ก ๊ด๋ฆฌํ์ฌ ๊ฐ๊ฐ ์ ์ฉํ๋ฉด ์ฝ๋๋ฅผ ์ค๋ณตํด์ ์ฌ์ฉํ์ง ์๋๋ค.
import styled from 'styled-components' // before const divWrapper = styled.div` font-size: 14px; background-color: red; ` const SectionWrapper = styled.section` font-size: 14px; background-color: red; ` // after import styled, { css } from 'styled-components' const cssVariable = css` font-size: 14px; background-color: red; ` const divWrapper = styled.div` ${cssVariable} ` const SectionWrapper = styled.section` ${cssVariable} `
๋ฐ์ํ
๋๊ธ