According to the React Static Boilerplate website, they use CSS Modules - this would explain why the body tag is being respected but the class selector is not.

https://github.com/css-modules/css-modules

try importing the stylesheet like so:

import styles from './MyComponent.css';

The using it in your component like so:

<div className={styles.card}>something!</div>

Answer from Toby on Stack Overflow
🌐
Reddit
reddit.com › r/react › css style not applying
r/react on Reddit: CSS style not applying
March 4, 2023 -

Hello, this is my first time working with React and I'm running into some issues.

I created a CSS file but it is not applying the styles when I use className or id. However it is applying the style when I use only

the html elements (i.e. h1, input, ul, etc).

I saved the css file in the src folder and wrote the import statement so I am very confused as to what's going on.

Please let me know if further information is needed and thank you in advance!

🌐
Quora
quora.com › Why-is-React-not-reading-a-CSS-file-React-js
Why is React not reading a CSS file (React.js)? - Quora
Answer: This is not a React problem, it is either a loading or css (class specificity, etc) problem. In the css file, add an [code ]!important[/code] css rule to turn all text red, targeting the body tag.
🌐
Reddit
reddit.com › r/reactjs › tailwind css classes appear in html but no styles are applied - react app + craco setup
r/reactjs on Reddit: Tailwind CSS classes appear in HTML but no styles are applied - React App + CRACO setup
August 8, 2025 -

i'm having a frustrating issue with Tailwind CSS in my Create React App project. The Tailwind classes are showing up in the HTML elements when I inspect them in DevTools, but absolutely no styles are being applied - everything just appears as plain black lines/text and on top of each other one line after another.

PS: for context i am a developper but this is my first project with react.js so i've been vibe coding my way through it , learning as i go everything i implement .

Setup:

  • React 19.1.1 with TypeScript

  • Create React App (react-scripts 5.0.1)

  • Tailwind CSS 3.4.17

  • CRACO 7.x for PostCSS support

  • Tested in both Chrome and Firefox - same issue

Configuration files:

tailwind.config.js:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
};

craco.config.js:

module.exports = {
  style: {
    postcss: {
      plugins: [
        require('tailwindcss'),
        require('autoprefixer'),
      ],
    },
  },
}

src/index.css:

@tailwind base;
@tailwind components;
@tailwind utilities;

/* rest of CSS... */

package.json

"scripts": {
  "start": "craco start",
  "build": "craco build",
  "test": "craco test",
  "eject": "react-scripts eject"
}

Test Component:

const TestComponent = () => {
  return (
    <div className="p-8 bg-red-500 text-white">
      <h1 className="text-2xl font-bold mb-4">Tailwind CSS Test</h1>
      <p className="text-lg">If you can see red background and white text with proper padding, Tailwind is working!</p>
      <div className="mt-4 p-4 bg-blue-500 rounded-lg">
        <p>This should be blue with rounded corners and padding</p>
      </div>
    </div>
  );
};

What I've tried:

  1. Installed CRACO and configured it properly

  2. Updated package.json scripts to use CRACO instead of react-scripts

  3. Verified Tailwind config content path includes all React files

  4. Confirmed u/tailwind directives are in index.css

  5. Development server compiles without errors

  6. Cleared browser cache and hard refreshed

The weird part: When I inspect the elements in DevTools, I can see the Tailwind classes are applied to the HTML elements (like class="p-8 bg-red-500 text-white"), but there are no actual CSS styles - no background colors, no padding, nothing. It's like the CSS isn't being generated or loaded.

Environment:

  • Windows 11

  • Node.js version: 24.2.0.0

  • npm version: 11.3.0

Has anyone encountered this before? What am I missing in my setup? The fact that the classes appear in the HTML but have no styling suggests the PostCSS processing isn't working correctly, but CRACO should handle that.

Any help would be greatly appreciated!

🌐
DhiWise
dhiwise.com › post › troubleshooting-guide-how-to-fix-react-css-not-applying
Troubleshooting Guide: Resolving React CSS Not Applying
May 30, 2024 - Debugging CSS issues in React involves several steps: Check the import statements in your JS file. Verify the CSS file syntax and ensure there are no errors. Use browser dev tools to inspect elements and see which styles are being applied.
🌐
Reddit
reddit.com › r/reactjs › css modules is not working in functional component help?????
r/reactjs on Reddit: CSS Modules is not working in functional component Help?????
March 19, 2020 -

i am facing issue when i am trying to scope css file to specific component in case of class component its working fine by following this article https://create-react-app.dev/docs/adding-a-css-modules-stylesheet

but in functional component this approach is not working

here is some my application details
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-scripts": "3.4.0"

here is my component
import React, { Component } from 'react';
import LS from './Layout.module.css';
// import './Layout.css'
import Aux from '../../hoc/Aux';

// const layout = (props) => (
//
// Toolbar Sidebar BackDrop
//
// {props.children}
//
//
// );

class layout extends Component {
render() {
return (

Toolbar Sidebar BackDrop

{this.children}

);
}
}
export default layout;

when i apply class approach the css is only scope to the layout file but i want to use finctional component but the scope css is not working when i use functional component

Top answer
1 of 7
13

In a react project created with create-react-app or npx create-react-app, I also had the same issue.

I had imported index.css file in my App Component but my styles were not being applied properly to my React Components.

I even tried directly adding index.css file in my html file in the public folder and using link tag to link to my index.css file (which resides within src folder).

<link rel="stylesheet" href="./../src/index.css">

That also didn't work.

Finally, I read an article about 7 ways to apply CSS into React. One best way was to install node-sass into our project and use index.scss ( import './index.scss') into App Component instead of index.css.

And Hurray!!! My CSS worked fine, All the Media Queries started to work fine.

Below is the code snippet you can try.

import React from "react";
import ReactDom from "react-dom";
import './index.scss';


// --- Data to work with ---
const books = [
  {
    id: 1,
    name: 'The Rudest Book Ever',
    author: 'Shwetabh Gangwar',
    img: 'https://m.media-amazon.com/images/I/81Rift0ymZL._AC_UY218_.jpg'
  },
  {
    id: 2,
    name: 'The Rudest Book Ever',
    author: 'Shwetabh Gangwar',
    img: 'https://m.media-amazon.com/images/I/81Rift0ymZL._AC_UY218_.jpg'
  },
  {
    id: 3,
    name: 'The Rudest Book Ever',
    author: 'Shwetabh Gangwar',
    img: 'https://m.media-amazon.com/images/I/81Rift0ymZL._AC_UY218_.jpg'
  },
  {
    id: 4,
    name: 'The Rudest Book Ever',
    author: 'Shwetabh Gangwar',
    img: 'https://m.media-amazon.com/images/I/81Rift0ymZL._AC_UY218_.jpg'
  },
];


const Book = ({ book }) => {
  return (
    <div className={"book"}>

      <img src={book.img} alt="book image" />

      <h3>{book.name}</h3>
      <p>{book.author}</p>
    </div>
  )
};

const Books = () => {
  return (
    <main className={"books"}>
      {
        books.map(book => {
          return (<Book book={book} key={book.id} />)
        })
      }
    </main>
  )
};


// Work a bit fast | one step at a time
const App = () => {
  return (
    <main>
      <h2>Books</h2>
      <Books />
    </main>
  )
}

ReactDom.render(<App />, document.getElementById("root"));
/* --- Mobile First Design --- */
.books{
  text-align: center;
};

.book{
  border: 1px solid #ccc;
  text-align: center;
  width: 200px;
  padding: 1rem;
  background: #001a6e; 
  color: #fff;
  margin:auto;
};

h2{
  text-align: center;
}

/* --- Adding Media Queries --- */
@media only screen and (min-width: 900px){
  .books,.persons{
    display:grid;
    grid-template-columns: 1fr 1fr;
  }
}

To install node-sass, simple do npm install node-sass --save Then rename all your .css files with .scss and your project with work properly.

The package.json should have the node-sass dependency added as shown below:

 "dependencies": {
    "node-sass": "^4.14.1",
    "react": "^16.8.3",
    "react-dom": "^16.8.3",
    "react-scripts": "2.1.5"
  },

Hope this will help many developers :)

2 of 7
4

It would be helpful to see your React component as well.

Given this code, you are passing className as a property into the component rather than assigning a class to it:

export default class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      data: null
    };
  }

  render() {
    return (
      <div>
        /** This line specifically **/
        <ContactList className="contactList" />
        <ContactDetail />
        <AddContactModal />
      </div>
    );
  }
}

Inside your component, you would need to use className={this.props.className} on a regular HTML tag inside of your component in order to pass the className through.

🌐
Reddit
reddit.com › r/tailwindcss › i just cannot figure out why my tailwind style is not being applied. it's version 4 with vite+react setup, and it shows no error
r/tailwindcss on Reddit: I just cannot figure out why my tailwind style is not being applied. It's version 4 with vite+react setup, and it shows no error
June 21, 2025 -

app.jsx:

// src/app.jsx
export default function App() {
return (
<h1 className="text-sm font-bold underline bg-blue-500">
Hello world!
</h1>
)
}

main.jsx:

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
)

index.css:

@import "tailwindcss";


import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss()],
})

vite.config.js:

Please help as i cannot move forward with development. I tried scourging on the internet. Some say running git init command helps, but it didnt work for me

🌐
Reddit
reddit.com › r/reactjs › create-react-app not building when css is in src folder
r/reactjs on Reddit: Create-react-app not building when css is in src folder
February 12, 2018 -

I have been using CRA for my project and for some reason it will not build (or deploy to heroku) when my css file is in any folder other than public. I have googled all over the internet and the only similar question had a problem solved by their own error in css. I have linted the css file and have found only warnings.

This is my current file structure

In index.js inside my src folder I have:

import React from 'react';
import ReactDOM from 'react-dom';
import './components/index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

And in every component file I have an import statement for the CSS.

I have tried moving the css file inside the src folder and changing the paths, but the only place it will successfully build is when it's inside the public folder with index.html and I link to the file.

I keep getting the error:

 ./src/index.css
Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'length' of undefined
at Array.forEach (<anonymous>)
    at <anonymous>

EDIT: I'm constantly doing trial and error to find the issue and it seems like it really is something that webpack may not be able to process in my css file. If I comment out the homepage.css file, it will build and work. I am currently trying to find the property that it cannot read. Anyone know if it's a css grid thing that it can't compile or if there is a list of properties that webpack can't compile?

EDIT 2: Ok guys I've spent like maybe 5 hours on this (including time from last night) and I finally find the problem. It seems that cra doesn't like me making my code cleaner and copying a banner gradient from Wes Bos' tutorial.

  background: linear-gradient(to var(--direction, left), var(--yellow), transparent);

This was the issue. The var(--direction, left) does not work with the css-compiler (i'm guessing) in cra. This code was used to make THIS type of banner and to make less code. It works in my local dev on Chrome and Firefox, but I guess it's a no-no for cra. Hope this may help anyone in the future!

Find elsewhere
🌐
Reddit
reddit.com › r/reactjs › tailwind styles are not being applied in my react app.
r/reactjs on Reddit: Tailwind styles are not being applied in my react app.
January 4, 2025 -

Hi guys. My tailwind styling is not being applied for some reason I cant figure out. I created a react project using vite then I noticed something was wrong when I tried to install tailwind, I had to use the -- legacy peps method to force install it, then when I wanted to add the postcss.config.js and tailwind.config.js files using the "npx tailwindcss init -p" command it would give me this error even though I installed tailwind. I tried manually creating the files but my styles are still not being applied. please help me out? Here is the Github-link for the project.

$ npx tailwindcss init -p
npm error could not determine executable to run
npm error A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2025-03-06T08_29_47_315Z-debug-0.log
🌐
Reddit
reddit.com › r/webdev › what could be causing css not being applied when deploying?
r/webdev on Reddit: What could be causing css not being applied when deploying?
March 23, 2021 -

FIXED! It was a semicolon at the end of another css file which was breaking everything. Just in case this helps someone else, if your css is not working well when deploying to netlify check those pesky semicolons in your css files!

I have a react app deployed to netlify and it's not picking up the css from one specific file while when in localhost it does work. I've checked the sources with the devTools and in the css main chunk I can see the css properties , specifically these:

.slick-slide>div{display:flex!important;justify-content:center!important}

I don't understand why it will work in localhost but not when deployed, anyone has any ideas ?

ps: I forgot to say that I'm using material-ui for mostly everything but this particular file is a separate css file I had to add to target something related to a slick-corousel I'm using. Maybe this could have something to do with the incidence? Although what's weird is that it works locally.

🌐
Reddit
reddit.com › r/reactjs › css in react
r/reactjs on Reddit: CSS in React
December 29, 2023 -

I’ve been building stuff in React for a couple of years now. Started as a complete web dev newbie and now I can comfortably code an app by myself. I understand React rendering and state pretty well now. But one area I feel I still don’t understand is CSS.

I never quite understood CSS. When I started, I was mostly working on small parts within a design system so most styling questions were answered for me. Then I moved to tailwind, which again has a lot of styles already in place.

I was doing pretty well with tailwind, but the first roadblock I hit was when I tried building a component library using tailwind. For the first time ever, my app’s styles and my libraries styles started clashing, and I started noticing weird styling issues I’d never seen in the past.

So I finally decided to bite the bullet and learn styling from the basics. I began researching various styling solutions in React that can and was bombarded with various libraries and CSS pre-processors - CSS-in-JS, SASS, css modules, etc.

Sorry for the long post, but my questions are - which of these are most people using and why? What’re the benefits of one over another? And finally which ones work best for styling large component libraries?

Edit: thanks for the suggestions everyone! Just to be clear I do understand the basics of HTML and CSS. I’ve built fairly complex components by myself (ex: https://rowstack.io). But the basics aren’t always enough when building a design system. Thats the part that is a bit intimidating.

🌐
Reddit
reddit.com › r/reactjs › i am struggling with css
r/reactjs on Reddit: I am struggling with css
October 22, 2021 -

I feel I am very fluent in React and using MUI as my UI framework yet i struggle alot when writing css.

Is it "normal" to struggle with css when you are alot better in writing components, algorithms,
defining architecture, doing object/array manipulation etc.? If so - how do i get better at css?

Top answer
1 of 5
6
I've been writing html since we used tables for layouts etc, so am used to writing plain html & css. I'm now a senior React engineer, and see this in all levels in my job! People just don't click with css, others outright hate it! I've also noticed some correlations between how people learned programming and hating css: if someone has come from an almost totally OOP based background, they struggle with the cascading part of how styles are applied. Most devs I meet have never written a web page without using a third party solution like bootstrap etc, so they have no idea about the limitations of CSS or how to do common tasks which are abstracted away behind utility classes. It's frustrating, arcane and unfortunately I don't think there's a shortcut to learning anything in development, same going for CSS! Try forgoing all third party shiz (bootstrap, mui, javascript even), except maybe a CSS reset, and write a 'pure' HTML/CSS component. You can port that to any javascript framework later, just get it to look how you want, even if that means copying the styles from your favourite css lib! And as I would recommend to everyone in frontend, read css-tricks.com and if you can, sign up for frontendmasters.com for some excellent FE learning materials. Best of luck and stick with it. It's an excellent skill! Also if you're ever feeling a bit silly about not knowing css, here's a clip of the creator of Redux, Dan Abramov having a hard time centering a div! 😁 We don't need to know all the things, just be aware and be able to find the solution! https://www.reddit.com/r/webdev/comments/r86vhe/dan_abramov_react_software_engineer_and_cocreator/?utm_source=share&utm_medium=mweb3x
2 of 5
3
I truly struggled with CSS that often times I would get too frustrated with it and drop whatever I was working on. It wasn't till I got an assignment at work to help with a design system and at that point I was pretty much living and breathing CSS. I would say over the span of a month working with it I actually come to really enjoy it. It took about two weeks to really catch on, but honestly most of what I was doing was taking images and making elements look like the input box, or button, or divider, etc. There was a lot of Googling (still is, even now I still search how to center a div haha) and watching videos but it took those two weeks for me to no longer get frustrated with it and actually learn it. Now using StyledComponents with React is really fun as you can see everything being styled almost instantly... not that you couldn't before, but being able to dynamically control CSS properties through props is awesome. My best advice is to dedicate some time during the week and look at designs and copy it. Everything from its active, disabled and hover states if possible. It really is (at least for me) just another muscle I needed to start working on.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Solving the React Error: Not Picking Up CSS Style | Pluralsight
To make this code work, you just have to save the CSS file inside the src folder. But if you still want to separate the files, just make a new folder inside the src folder. Below is the correct code for importing the CSS file. import React, {Component} from 'react'; import ReactDOM from 'react-dom'; import '../src/CSS_Files/style.css';
🌐
Reddit
reddit.com › r/reactjs › tailwind css not applying styles in vite + react (no errors, builds fine)
r/reactjs on Reddit: Tailwind CSS not applying styles in Vite + React (no errors, builds fine)
March 17, 2025 -
I'm currently using **Vite (6.3.3)** + **React** with **Tailwind CSS (v4.1.4)** on an Ubuntu Linux machine. My environment appears to be set up correctly according to the latest docs (as of April 2025). The build completes without errors, and the dev server (`npm run dev`) runs without issues. Tailwind compiles, but my styles are not being applied at all.

**Specifically:**

- The `vite.config.js` is standard:
```js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});
```

- `postcss.config.js` is:
```js
export default {
  plugins: {
    '@tailwindcss/postcss': {},
    autoprefixer: {},
  },
};
```

- `tailwind.config.js` is:
```js
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,jsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
```

- `src/index.css` correctly imports Tailwind:
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```

- In `src/main.jsx`, I'm importing `index.css` explicitly:
```jsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.jsx';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
```

- My `App.jsx` component:
```jsx
export default function App() {
  return (
    <div className="flex items-center justify-center h-screen bg-blue-600 text-white">
      <h1 className="text-3xl font-bold">
        Tailwind is working!
      </h1>
    </div>
  );
}
```

**Issue:**  
When loading the page (`localhost:5173`), it simply displays the text without Tailwind's styling. Developer tools console shows no errors or warnings. Tailwind clearly compiles but doesn't style the output.

**Additional context:**  
- Ubuntu Linux environment (permissions are fine)
- Incognito browser session for testing
- No caching issues

This feels like something subtle but critical. Has anyone encountered this with recent Tailwind + Vite + React setups (April 2025)? Appreciate any insights, as I'm currently stuck after verifying and double-checking every configuration file.
🌐
Reddit
reddit.com › r/tailwindcss › tailwind css not applying styles in vite + react (no errors, builds fine)
r/tailwindcss on Reddit: Tailwind CSS not applying styles in Vite + React (no errors, builds fine)
April 27, 2025 -

I am very new to all of this and have spent days trying to figure this out. Any help would be greatly appreciated.

I'm currently using **Vite (6.3.3)** + **React** with **Tailwind CSS (v4.1.4)** on an Ubuntu Linux machine. My environment appears to be set up correctly according to the latest docs (as of April 2025). The build completes without errors, and the dev server (`npm run dev`) runs without issues. Tailwind compiles, but my styles are not being applied at all.

**Specifically:**

- The `vite.config.js` is standard:
```js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});
```

- `postcss.config.js` is:
```js
export default {
  plugins: {
    '@tailwindcss/postcss': {},
    autoprefixer: {},
  },
};
```

- `tailwind.config.js` is:
```js
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,jsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
```

- `src/index.css` correctly imports Tailwind:
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```

- In `src/main.jsx`, I'm importing `index.css` explicitly:
```jsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.jsx';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
```

- My `App.jsx` component:
```jsx
export default function App() {
  return (
    <div className="flex items-center justify-center h-screen bg-blue-600 text-white">
      <h1 className="text-3xl font-bold">
        Tailwind is working!
      </h1>
    </div>
  );
}
```

**Issue:**  
When loading the page (`localhost:5173`), it simply displays the text without Tailwind's styling. Developer tools console shows no errors or warnings. Tailwind clearly compiles but doesn't style the output.

**Additional context:**  
- Ubuntu Linux environment (permissions are fine)
- Incognito browser session for testing
- No caching issues

This feels like something subtle but critical. Has anyone encountered this with recent Tailwind + Vite + React setups (April 2025)? Appreciate any insights, as I'm currently stuck after verifying and double-checking every configuration file.
🌐
Render
community.render.com › t › css-errors-when-deploying-react-app › 8053
CSS errors when deploying React app - Render
November 8, 2022 - Hello! I’ve been having some troubles deploying my React app as a static app. The app is correctly deployed and working well, but my App.css file is not taken into account. When running the app locally, I’ve got no issue, but when deploying on Render, the styles specified in the App.css ...
🌐
GitHub
github.com › facebook › create-react-app › issues › 13597
CSS is not working correctly after applying the React code Splitting. · Issue #13597 · facebook/create-react-app
May 23, 2024 - if I go to another component and come back the CSS is working correctly.
Published   May 23, 2024
Author   lalit-tudip