์ปดํฌ๋ํธ์ attribute ๊ณ ์ ์ผ๋ก ์ฌ์ฉํ๊ธฐ
import styled from "styled-components";
function App() {
return (
<div>
<form>
<Input />
<Input />
<Input />
<button type="submit">submit</button>
</form>
</div>
);
}
const Input = styled.input.attrs({ required: true })`
color: skyblue;
`;
export default App;

attribute๋ฅผ props๋ก ์ ๋ฌ๋ฐ์ ์ฌ์ฉํ๊ธฐ
import styled from "styled-components";
function App() {
return (
<div>
<Box fontColor="white" bgColor="#222">
Box1
</Box>
<Box fontColor="yellow" bgColor="tomato">
Box2
</Box>
<Box fontColor="blue" bgColor="#dbdbdb">
Box3
</Box>
</div>
);
}
const Box = styled.div`
display: flex;
justify-content: center;
align-items: center;
width: 100px;
height: 100px;
background-color: ${(props) => props.bgColor};
color: ${(props) => props.fontColor};
`;
export default App;

์ปดํฌ๋ํธ์ selector ์ฌ์ฉํ๊ธฐ
import styled from "styled-components";
function App() {
return (
<div>
<Input placeholder="hello!" />
<Input placeholder="world!" />
</div>
);
}
const Input = styled.input`
background-color: beige;
&:focus {
color: white;
background-color: #222;
}
`;
export default App;
