React TutorialLesson 40Free preview
React CSS-in-JS
This lesson is part of React · All levels
Summary
CSS-in-JS writes styles directly into JavaScript through a library such as styled-components. You make the component that already carries the underlying style, so the style moves along with the component that wears it. This approach makes the styling modular and can respond to props and states.
Key points
- You need to add packages like styled-components
- It produces a React component that is already stylish.
- Style can be made dynamic through interpolation of props.
- The style is close to the code so it's easy to reuse.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.