From the course: CSS for Programmers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
CSS-in-JS example: Styled Components and CSS Modules - CSS Tutorial
From the course: CSS for Programmers
CSS-in-JS example: Styled Components and CSS Modules
- Let's take a look at two popular and very different approaches to CSS and JS. So you see how big the spread is here and get your bearings for when you encounter these, or similar, in real world projects. And a quick side note, the examples provided in the exercise files for this movie are not functional, meaning you can't run them in live server as is. They serve as prototypical examples of how these approaches work. Running them as live code requires a full react setup which falls well outside the scope of this course. However, if you plug these components into a React project, they will work. The first solution we'll look at is styled components. This is a popular approach to CSS and JS used by React developers, and I'm using it as the first example because it is very much a "let's make CSS into JavaScript" approach to CSS. The idea of style components is in the name. You take a component, add CSS styles to it and…