Tailwind CSS does not work with react app - no affect

Syed Laeeq Ahmed

I am trying to create a react website using npx create-react-app myapp cd my app later i followed the steps as per mentioned on tailwind css that are as followed: npm install -D tailwindcss postcss autoprefixer and then npx tailwindcss init -p followed by this i added the following statement to tailwindconfig:

module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

later added the following to index .css

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

my app.js looked like following:

import './index.css'

function App() {
  return (
    <div className="App">
      <h1 className='text-orange-500' >Navbar</h1>
    </div>
  );
}

export default App;

still the tailwind is not taking any affect please help folder structure is as followed; enter image description here

the browser displays as it is enter image description here

Bhavesh Daswani

You might be having issue with tailwind.config.js can you try the below tailwind.config.js, In Create React App, the components are stored in src directory and you are targeting specific to pages and components directory, so going with .src/pages//, .src/pages/, .src/components//, .src/components/, may work you, Give it a try.

    module.exports = {
      content: [
        ".src/pages/**/*.{js,ts,jsx,tsx}",
        ".src/components/**/*.{js,ts,jsx,tsx}",
".src/components/*.{js,ts,jsx,tsx}",
".src/pages/*.{js,ts,jsx,tsx}",
      ],
      theme: {
        extend: {},
      },
      plugins: [],
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tailwind CSS does not work with React App

React App adding Pure CSS to Tailwind CSS

Tailwind CSS not loading custom classes on React app

Tailwind CSS not displaying using Create React App

"SyntaxError with Tailwind CSS in React app: 'font' class does not exist. How to resolve?"

How to use Tailwind CSS in React to configure Create React App?

CSS (Tailwind) + React.ts overflow doesn't work

Navbar in React and Tailwind CSS

tailwind css does not apply dark mode on react project

Tailwind classes not rendering in react app

Does affect yellow warining on react-native app perfromance?

How to change the primary color of the app from app's UI in React JS(Next JS) using tailwind CSS

Tailwind CSS classes is not working with React, error "You need to enable JavaScript to run this app..."

React tailwind, cannot pass tailwind css from parent to child

Border color doesn't work in Tailwind CSS

edit config of tailwind does not work as expected

my tailwind utility class does not work in production

Tailwind CSS partially working in NextJS app

Tailwind CSS responsive behavior on nextjs app

Title not updating in nextjs, tailwind css app

Create React App build does not work correctly

Duplicating a React app folder does not work?

Dockerized React app - HTTPS=true does not work

kubernetes DNS does not work in react app

React Tailwind - not able to start my app

Tailwind CSS - NavBar does not overlap the content

Css transition does not work for the first run in React

React css transition does not work correctly

React importing image does not work for CSS