question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React: Tailwind CSS 3 doesn't work

See original GitHub issue

Current Behavior

If you try to add TailwindCSS to a React project, the tailwind styles are never generated when serving or buildings.

Expected Behavior

  • Tailwind styles are applied

Steps to Reproduce

Failure Logs

  • No failure logs

Environment

  Node : 14.18.1
  OS   : darwin x64
  yarn : 1.22.17
  
  nx : 13.3.6
  @nrwl/angular : undefined
  @nrwl/cli : 13.3.6
  @nrwl/cypress : 13.3.9
  @nrwl/devkit : 13.3.9
  @nrwl/eslint-plugin-nx : 13.3.9
  @nrwl/express : undefined
  @nrwl/jest : 13.3.9
  @nrwl/linter : 13.3.9
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : undefined
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.3.9
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.3.6
  @nrwl/web : 13.3.9
  @nrwl/workspace : 13.3.6
  @nrwl/storybook : 13.3.9
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 6.6.7
  ---------------------------------------
  Community plugins:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
puku0xcommented, Dec 18, 2021

It works for me. I guess you forgot adding a glob pattern for your app.

// apps/<app-name>/postcss.config.js
module.exports = {
  plugins: {
    tailwindcss: {
      config: 'apps/<app-name>/tailwind.config.js',
    },
    autoprefixer: {},
  },
};
// apps/<app-name>/tailwind.config.js
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');

module.exports = {
  content: [
    'apps/<app-name>/src/**/*.{js,jsx,ts,tsx}',
    ...createGlobPatternsForDependencies(__dirname),
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
// apps/<app-name>/src/styles.css
@tailwind base;
@tailwind components;
@tailwind utilities;
3reactions
rogerfarcommented, Jan 21, 2022

Could the docs be updated to reflect tailwind 3? Right now it’s installing the latest version but the instructions, and generated config files, are wrong.

This is the config that works for me:

module.exports = {
  plugins: {
    tailwindcss: { config: 'tailwind.config.js' },
    autoprefixer: {},
  },
};
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');

module.exports = {
  content: [
    '../../apps/**/*.{js,jsx,ts,tsx}',
    '../../libs/**/*.{js,jsx,ts,tsx}',
    ...createGlobPatternsForDependencies(__dirname),
  ],
  theme: {
    extend: {},  
  },
  variants: {
    extend: {},
  },
  plugins: [],
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

tailwindcss not working in create-react-app - Stack Overflow
In your .js/.jsx where you want to use the Tailwindcss ... tailwind docs didn't work for me, then I just went to. tailwind.config...
Read more >
Install Tailwind CSS with Create React App
Install tailwindcss and its peer dependencies via npm, and then run the init command to generate both tailwind.config.js and postcss.config.js .
Read more >
How to use TailwindCSS with react | by Kyosuke Ito
As I would like to use TailwindCSS, I tried to introduce my app and I found ... your opacity like rgb(255, 255, 255,...
Read more >
Tailwindcss Suggestions not working in react-app : WEB-48464
Tailwindcss Suggestions not working in react-app · make sure that the following files exist: node_modules/tailwindcss/tailwind.css and node_modules/. · if you use ...
Read more >
How to add Tailwind into a React project in under a minute
The worst thing that could happen while not working tailwind CSS code is if you forget to include the generated CSS file in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found