...

/

CSS Modules in React

CSS Modules in React

Let's see how styling can be done using CSS Modules in a React App.

We'll cover the following...

CSS Modules are an advanced CSS-in-CSS approach. The CSS file stays the same, where you could apply CSS extensions like Sass, but its use in React components changes. To enable CSS modules in create-react-app, rename the src/App.css file to src/App.module.css. This action is performed in the command line from your project’s directory:

Press + to interact
mv src/App.css src/App.module.css

Note: This command is to be executed when you run this on your local machine. You can see the live execution of code at the end of this lesson.

In the renamed src/App.module.css, start with the first CSS class definitions, as before: ...

Access this course and 1400+ top-rated courses and projects.