skip to Main Content

I’ve build an app using create-react-app and then installed tailwindcss and postcss. I’ve followed the config for applying tailwind but my classes still aren’t being applied. I have tried specifying the files in the config but it’s still picking up:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/App.jsx",
    "./src/*.{js,jsx,html}",
    "./src/**/*.{js,jsx,html}",
    "./src/components/**/*.{js,jsx,html}",
  ],
  theme: {
  },
  plugins: [],
}

this is the index.css:

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

and this is the src/App.jsx where I apply the class:

import React from 'react';

function App() {
  return (
    <div className='App'>
      <div className='flex flex-col'>
        <div className='flex bg-black'>
          <span>How to find us</span>
        </div>
        <div className='flex'>
          <Component />
        </div>
      </div>
    </div>
  );
}

export default App;

I have run npx tailwindcss -i ./src/index.css -o ./dist/output.css and have restarted the server, cleared cache and uninstalled and reinstalled tailwind but it still isn’t working. Is there something I have missed?

2

Answers


  1. Try to check you node_modules the directory of /tailwindcss
    Then try to add this line to your src/App.jsx

    import 'tailwindcss/tailwind.css'; 
    
    Login or Signup to reply.
  2. recommend using vite to create react app: https://vitejs.dev/guide/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search