32

I created a ReactJS project using create-react-project command. I npm installed tailwindcss and created a tailwind.config.js file.

Now to make my life easier I also installed an extension called Tailwind CSS IntelliSense and reloaded VSCode. The extension still does not give suggestions in my JavaScript files.

At first, i thought it is maybe because it works only with html extensions or that the reactjs files uses className for adding CSS classes as class keyword is reserved. So, I tried to edit index.html file but not suggestions in HTML files as well.

Please tell what else can I tryout?

2
  • I have the same problem, how did you manage to solve it ? Commented Aug 3, 2020 at 15:08
  • Create React App was one of the key tools for getting a React project up-and-running in 2017-2021, it is now in long-term stasis and we recommend that you migrate to one of React frameworks documented on Start a New React Project. - See more here: How to install React with TailwindCSS v4 Commented Mar 30 at 19:53

21 Answers 21

52

Edit your settings.json as below:

{
  // other settings
  "tailwindCSS.includeLanguages": {
    "javascript": "javascript",
    "html": "HTML"
  },
  "editor.quickSuggestions": {
    "strings": true
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This didn't work for me because I was using typescript. If you're using typescript also add "typescript": "typescript" under the javascript property
30

Here's how to get Tailwind Intellisense to work with React files

  1. Go to Tailwind CSS settings and add Javascript support "tailwindCSS.includeLanguages": { "plaintext": "javascript" }
  2. Reload vscode

If this doesn't fix things, try using ctrl + space before adding a class name.

View image of Tailwind settings

2 Comments

cmd + shift + p to open JSON settings in VSCode. You can then add the suggested code there
It only works when I press ctrl + space but now I'm wondering why It doesn't work normally
17

I faced this issue even after configuring tailwindCSS.includeLanguages settings.

So make sure you configure the below settings as well to allow suggestions inside a string.

"editor.quickSuggestions": {
    "strings": true
}

1 Comment

I had been having issues with the Tailwind Intellisense for a while now in VS code. The combination I used was a combination of chancruze's answer above AND this answer adding the quickSuggestions to turn strings on (true). Now it works perfectly.
7

Add to settings.json

You can open via

cmd + shift + p => Prefences: Open Settings (JSON)

"tailwindCSS.includeLanguages": {
    "javascript": "javascript",
    "javascriptreact": "javascript",
    "typescript": "typescript",
    "typescriptreact": "typescript",
}

1 Comment

The typescript part did it for me.
6

Try to delete the "tailwind.config.js" and create it back again with

npx tailwindcss init

and it should start working.

1 Comment

This solution worked for me, I did init nextjs app with the command npx create-next-app@latest but tailwindcss intellisense had a problem for some reason. Had to init tailwindcss again for intellisense to work.
5

Add this at the end of your setting.json file in order to get IntelliSense on both HTML and js file

"tailwindCSS.includeLanguages": {
    "javascript": "javascript",
    "html": "HTML"
  },

Comments

3

I had the same issue. I uninstalled Tailwind CSS IntelliSense, then reinstalled it back. And the problem was solved.

1 Comment

Not working for me.
2

You have to include the files, in which you want to work with Tailwind CSS in your tailwind.config.js file. You can replace:

content: [],

with

content: ["*"],

It will include all files in your project. Save it and now the Tailwind CSS IntelliSense will popup the suggestions.

1 Comment

Not recommended. In v3, only declare the paths that are actually used to preserve performance.
1

Both combined worked for me.

   "tailwindCSS.includeLanguages": {
        "javascript": "javascript",
        "html": "HTML"
      },

and

Try to delete the "tailwind.config.js" and create it back again with

npx tailwindcss init

Comments

1

according to Tailwind CSS IntelliSense extension details page:

editor.quickSuggestions

By default VS Code will not trigger completions when editing "string" content, for example within JSX attribute values. Updating the editor.quickSuggestions setting may improve your experience:

"editor.quickSuggestions": { "strings": "on" }

Comments

0

Placed the following snippit in VSCode’s settings.json file.

"tailwindCSS.emmetCompletions": true, // remove this line if you don't use Emmet
"editor.inlineSuggest.enabled": true,
"editor.quickSuggestions": {
   "strings": true
},
"css.validate": false,

Comments

0

The last version of tailwindcss for this time is 3.2.1 and it seems this version is not matched with the last version of vsCode or IntelliJ IDEA so I downgraded tailwind to 3.1.8 (npm i [email protected]) and then those ways that guys suggest work now

Comments

0

I added these lines of code but it did not work. However, updating my vscode to the latest version did the trick for me.

    "tailwindCSS.includeLanguages": { "plaintext": "javascript" },
    "tailwindCSS.emmetCompletions": true,
    "editor.inlineSuggest.enabled": true,
    "editor.quickSuggestions": {
        "strings": true
    },
    "css.validate": false,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    }

Comments

0

I had the same issue I fixed by just creating a file in the root folder in my project named tailwind.config.js, then it was working fine.

Comments

0

If it helps, my scenario is that I'm using WSL to "store" my projects but my VS code was installed in my windows. What I did was open the WSL prompt, navigate to the project folder and run code .. This is what worked for me and I was struggled on that for a few days

Comments

0

Try this if you still can not fix this problem:

  1. Uninstall Tailwind CSS Intellisense from your VSCode and close it
  2. Go to where your vscode exntensions are stored, mine is "C:\Users\Admin.vscode\extensions" (You can open this folder by pressing Ctrl + Shift + P in VSCode, and then search for "Extensions: Open Extensions Folder")
  3. Check if there're any folders called bradlc.vscode-tailwindcss, if yes then delete all of those
  4. Now, re-open your VSCode and install Tailwind CSS Intellisense once again

3 Comments

how to fix it on macos?
It's the same on macos, you will have to find the directory leading to where the vscode extensions are stored, on macOS it's ~/.vscode/extensions. You can open that folder by using this shortcut in VSCode: Ctrl + Shift + P. And then search for "Extensions: Open Extensions Folder"
Not working for me.
0

After trying everything mentioned above, I simply updated my VS Code, which fixed the problem.

Comments

0

To me I added; content: [ './pages/**/*.{html,js}', './components/**/*.{html,js}', ] Inside the content and it started working fine after that, I used vite to create my react aplication

Comments

0

Some extensions can cause such issues

I ran into the same issue where Quick Suggestions stopped working after installing the Explorer Exclude extension. Disabling the extension resolved the problem, suggesting potential conflicts between Quick Suggestions and Explorer Exclude.

Comments

0

In my case in tailwind.config.cjs was in "export default({})" which I replaced with "module.exports = {}". In the output of VScode, it was showing that Taiwind CSS IntelliSense was having a problem with ES6 modules. After doing "module.exports" Taiwind CSS IntelliSense was providing auto suggestions for className s'.

Comments

0

User setting UI

Using Ctrl+shit+p and Preference: User Settin(UI). In the setting under user tab checking the Tailwind CSS:Emment Completions solved it for me.

Not important for this but for safer side I was working with Vite + React and added tailwind at later point of the project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.