Normally you would put them next to the component. Component.tsx component.module.css Answer from _AndyJessop on reddit.com
🌐
Create React App
create-react-app.dev › docs › adding-a-css-modules-stylesheet
Adding a CSS Modules Stylesheet | Create React App
January 4, 2019 - Learn more about CSS Modules here. ... import React, { Component } from 'react'; import styles from './Button.module.css'; // Import css modules stylesheet as styles import './another-stylesheet.css'; // Import regular stylesheet class Button extends Component { render() { // reference as a js object return <button className={styles.error}>Error Button</button>; } } Copy
🌐
W3Schools
w3schools.com › react › react_css_modules.asp
React CSS Modules
In React, CSS Modules are CSS files where class names are scoped locally by default.
Discussions

Real-world projects using CSS modules?
Normally you would put them next to the component. Component.tsx component.module.css More on reddit.com
🌐 r/reactjs
7
14
March 11, 2024
reactjs - How to apply global styles with CSS modules in a react app? - Stack Overflow
I'm currently using CSS Modules with React for my styling. So each of my components is importing in it's component specific css file, like so: import React from 'react'; import styles from './App.... More on stackoverflow.com
🌐 stackoverflow.com
reactjs - How to use css modules with create-react-app? - Stack Overflow
According to a tweet by Dan Abramov, CSS modules support is there in create-react-app (CRA). One just needs to give extension of module.css to his stylesheets to enable the feature, but this is not More on stackoverflow.com
🌐 stackoverflow.com
[Discussion] CSS Modules

This is an excellent talk on CSS modules that gives solid context on why you may want to use them in a historical context.

As for how to use them in CRA v2, you can do the following:

import styles from './styles.module.css'

export default () => (
<div className={styles.example} />
)

and styles.module.css:

.example {
width: 20px;
height: 20px;
background: red;
}
More on reddit.com
🌐 r/reactjs
3
3
September 27, 2018
🌐
Medium
medium.com › @ralph1786 › using-css-modules-in-react-app-c2079eadbb87
Using CSS Modules In React App. Welcome back reader to another blog… | by Rafael Cruz | Medium
February 23, 2022 - CSS Modules is a great approach for making CSS locally scoped and for preventing naming clashes in medium to large projects. I hope you were able to gain a better understanding of how CSS Modules work, their benefits and how you can implement them into your React application.
🌐
GitHub
github.com › gajus › react-css-modules
GitHub - gajus/react-css-modules: Seamless mapping of class names to CSS modules inside of React components. · GitHub
If you are not familiar with CSS Modules, it is a concept of using a module bundler such as webpack to load CSS scoped to a particular document. CSS module loader will generate a unique name for each CSS class at the time of loading the CSS ...
Starred by 5.2K users
Forked by 214 users
Languages   JavaScript
🌐
Docureacten
docureacten.github.io › css modules
CSS Modules | React.js: Learn Easily with Examples
CSS Modules are CSS files where all class and animation names are scoped locally by default. This means that when you import a CSS Module into a React component, the styles defined within that module only apply to that component.
🌐
npm
npmjs.com › package › react-css-modules
react-css-modules - npm
Seamless mapping of class names to CSS modules inside of React components.. Latest version: 4.7.11, last published: 7 years ago. Start using react-css-modules in your project by running `npm i react-css-modules`. There are 324 other projects in the npm registry using react-css-modules.
      » npm install react-css-modules
    
Published   May 11, 2019
Version   4.7.11
Author   Gajus Kuizinas
Find elsewhere
🌐
OpenReplay
blog.openreplay.com › using-css-modules-in-react
Using CSS Modules in React
September 2, 2022 - In React js, where classes function similarly to local variables in JavaScript, a CSS Module is just a .css file. It lessens React styling’s global scope. Additionally, it is a tool that prevents global scope and collisions by producing a random string as a className name and adding a unique hash to make each className unique.
🌐
Medium
medium.com › @gopi07it › css-modules-in-react-7f86b2e822ef
CSS Modules In React | Medium
January 1, 2025 - CSS Modules In React CSS Modules allow developers to write CSS styles that are scoped to specific components. Each component can have its own CSS file, ensuring that styles do not leak out and affect …
🌐
Pusher
pusher.com › blog › css-modules-react
Getting started with CSS modules in React | Pusher blog
We also learned about the methods of including CSS in our React components. While both methods share certain advantages, the implementation differs: one is actual CSS living in CSS files wired with JS modules using imports and hashed class names at build time, the other is actual JS from the start and is composed and attached to elements in the form of inline styles at execution time.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
React CSS modules - Visual Studio Marketplace
Extension for Visual Studio Code - React CSS modules - VS code extension for CSS modules support in React projects written in typescript.Supports Definitions, Hover , Completion Providers and Diagnostics
🌐
DhiWise
dhiwise.com › post › how-to-structure-and-organize-react-css-modules
Best Practices for Structuring React CSS Modules
August 20, 2024 - CSS Modules are CSS files in which all class names and animation names are scoped locally by default. This means that the CSS code you write is tied to a specific component and won't interfere with the CSS code of other components.
🌐
Testmuai
testmuai.com › testmu ai › blog › how to use css modules with react applications | testmu ai
How to Use CSS Modules With React Applications | TestMu AI (Formerly LambdaTest)
This demonstrates the power of CSS Module composition in action! As we are done creating the logic for navigation links and buttons, let’s create the HeroSection and other necessary components. import React from 'react' import HeroImage from '../HeroImage/HeroImage' import HeroText from '../HeroText/HeroText' import styles from './HeroSection.module.css' export default function HeroSection() { return ( <section className={styles.section}> <HeroText /> <HeroImage /> </section> ) }
Published   January 10, 2026
🌐
CoreUI
coreui.io › answers › how-to-style-components-with-css-modules-in-react
How to style components with CSS modules in React · CoreUI
October 4, 2025 - Use CSS modules with .module.css extension and import class names for scoped component styling.
🌐
Robin Wieruch
robinwieruch.de › react-css-modules
How to use CSS Modules in React - Robin Wieruch
October 19, 2019 - That’s already it for the CSS Modules setup in Webpack. Next, you can define your first CSS file. Let’s name it src/style.css: ... Then you can import the CSS file in one of your React components. Afterward, you are already able to use the CSS class defined in the CSS file in your React component.
🌐
CSS-Tricks
css-tricks.com › css-modules-part-3-react
CSS Modules and React | CSS-Tricks
June 15, 2022 - Since the is the hello world of CSS, we’re going to create a Button module. And although I’ll be sticking with Webpack’s CSS loader and what I used in the previous tutorial, there are alternatives. This is the sort of file structure that we’d like in this project: ... We’ll then import this custom React component into one of our templates.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-do-css-modules-help-in-styling-react-components
How do CSS Modules help in styling React components? - GeeksforGeeks
July 23, 2025 - CSS Modules help in styling React components by providing a way to create modular stylesheets where each component's styles are contained within its own module.
Top answer
1 of 11
126

You do not need to eject.

Create React App supports CSS Modules right out of the box as of version 2.

Upgrade to the latest (react-scripts@latest) version.

If you use yarn:

Copyyarn upgrade react-scripts@latest

If you use npm:

Copynpm install --save react-scripts@latest

Then you just have to create a file with the extension .module.css

For example:

Copy.myStyle {
  color: #fff
}

Then you can use it like so:

Copyimport React from 'react'
import styles from './mycssmodule.module.css'

export default () => <div className={styles.myStyle}>We are styled!</div>
2 of 11
11

To enable CSS module in to your app, you don't need to eject create-react-app. You can follow these simple steps described in this link to use CSS module in your project.

But in case if you ejected your create-react-app, then you must find file named

"webpack.config.js"

open this file and find this {test:cssRegex....etc} in line no. 391 and replace to this changes:

Copy            {
              test: cssRegex,
              exclude: cssModuleRegex,
              use: getStyleLoaders({
              importLoaders: 1,
              modules: true,
              localIdentName: '[name]__[local]__[hash:base64:5]'
            }),
            },

Open .js file and import statement like this

Copyimport cssStyleClassName from './MyApp.css';

Then this import statement allow you to do following changes in component tags like this

Copy<div className={cssStyleClassName.styleName}></div>

styleName is what you defined in your MyAppStyle.css file

Copy.styleName{
your properties here...
}

After eject your app, you must restart your local server, sometime changes don't get reflect.

Note In earlier version there were two generated file for production and dev separately. Now in current version one file named "webpack.config.js" file for which you need to concerned for changes. Thank you.

🌐
Adobe Developer
developer.adobe.com › commerce › pwa-studio › guides › general-concepts › css-modules
CSS modules
PWA Studio supports CSS modules out-of-the-box and using them is the recommended approach for styling components. React lets you split the UI into independent and reusable components, which allows you to update small parts of your UI without refreshing the page.