Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- git lab
- Git
- input type=file
- getModifierState
- 컨디셔널 렌더링
- API 토큰
- createGlobalStyle
- npm styled-reset
- nextjs .env
- rewrites
- github io
- dart 변수
- bootstrap
- react typescript
- styled components
- react
- react env
- nextjs 설치
- fetch
- API token
- github
- icon
- nextjs
- typescript react
- SCSS
- CSS
- next.js css
- There isn’t anything to compare
- ngrok설치
- ngrok실행
Archives
- Today
- Total
꾸준히 성장하는 개발자
[React] styled-reset _2 ( createGlobalStyle 전역 스타일로 관리 ) 본문
createGlobalStyle
- 한 컴포넌트를 만들 수 있게 해 주는데 렌더링 될 때, 그 컴포넌트는 전역 스코프에 스타일을 올려준다
import { createGlobalStyle } from 'styled-components'
const GlobalStyle = createGlobalStyle`
body {
fontSize: 16px;
}
`;
function App() {
return (
<>
<GlobalStyle />
<Router />
</>
);
}
export default App;
GlobalStyle이라는 전역적으로 넣어줄수 있는 컴포넌트를 생성하고
component들 가장 위에 넣어주면 된다.
위처럼 넣어주게 되면 전역적으로 스타일을 넣어준것이다.
모든 body의 폰트 사이즈는 16픽셀이 된다.
이걸 이용해서 초기에 styled-reset을 해줄 수 있다.
import { createGlobalStyle } from 'styled-components'
const GlobalStyle = createGlobalStyle`
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
*{
box-sizing:border-box;
}
body{
font-family: 'Source Sans Pro', sans-serif;
}
a{
text-decoration: none;
color: inherit;
}
`;
function App() {
return (
<>
<GlobalStyle />
<Router />
</>
);
}
export default App;
'React' 카테고리의 다른 글
[React] vite 사용해보기 (0) | 2022.06.13 |
---|---|
[React Hook] useParams (0) | 2022.06.08 |
[React] styled-reset _1 (npm i styled-reset) (0) | 2022.06.07 |
[React] 컨디셔널 렌더링 ?? (0) | 2022.05.31 |
[React with TypeScript] (1) | 2022.05.27 |