TIL - styled-components
4232 ワード
Today I Learned
毎日習ったことを整理して記録する.sty-componentsを学びました.
CSS-in-JS
styled-components
npm install --save styled-components
codeimport React from 'react'
import styled, { css } from 'styled-components'
const Button = styled.button`
background: transparent;
border-radius: 3px;
border: 2px solid palevioletred;
color: palevioletred;
margin: 0.5em 1em;
padding: 0.25em 1em;
${props => props.primary && css`
background: palevioletred;
color: white;
`}
`;
const Container = styled.div`
text-align: center;
`
render(
<Container>
<Button>Normal Button</Button>
<Button primary>Primary Button</Button>
</Container>
);
const Button = styled.button``
resultテンプレート文字のタグ付け
Reference :
Reference
この問題について(TIL - styled-components), 我々は、より多くの情報をここで見つけました https://velog.io/@qmasem/TIL-styled-componentsテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol