Using CSS and React Components
Where Stimulus encourages using the markup you are already writing, therefore keeping CSS in its own separate files, React encourages thinking about CSS and code together. Once you get in the habit of thinking of your page as made up of a number of different React components, it’s only a small step to imagine those components as containing their own CSS for features that are specific to that component.
Including CSS with React code is such a common thought that there are oodles of libraries that handle this. I’m going to talk about one of these libraries that has an interesting way to insert CSS into your React code: styled-components.
What Is the styled-components Library?
The styled-components library allows ...
Get Modern Front-End Development for Rails now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.