106

So the description of the plugin is that it'll display suggestions of classes when am working on the markup, but it doesn't. I've reloaded the plugin countless times. I even restarted VSCode and eventually re-installed it.

I have installed TailwindCSS correctly (followed docs). The issue with the extension persists after a proper installation of any version of TailwindCSS, even though the installation was successful and fully functional:

  • In TailwindCSS v3, I created and properly configured the tailwind.config.js.
  • In TailwindCSS v4, without any JS file, I used the CSS-first approach with @import "tailwindcss"; in my main CSS file.

So TailwindCSS itself works fine, but the VSCode TailwindCSS IntelliSense extension does not.

12
  • 1
    I'm also new to tailwind, but it is working for me. Are you pointing to a compiled version of tailwind.css in your html file? For me it's about 1MB. Commented Apr 21, 2020 at 12:25
  • No, I don't think I've been working with that file. How do I get it? Commented Apr 21, 2020 at 13:02
  • For me, I added the syler.sass-indented extension, and then Tailwind IntelliSense started working for me. Commented Oct 10, 2020 at 0:16
  • 1
    On my side reopening project helped. Commented Dec 25, 2020 at 22:00
  • Anyone stumbling over the same issue of tailwind completion not happening in .erb files, see Tailwind CSS autocomplete in VSCode with Ruby on Rails. It was the key for me. Commented Jan 7, 2022 at 23:56

51 Answers 51

194

Its actually a pretty simple fix. open your settings.json file then add this to get the intellisense working on all files

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

10 Comments

This gives you hinted description of the css which is added by each class too.
The only thing needed to get autosuggestions to work was: "editor.quickSuggestions": { "strings": true } not sure why you include the other stuff?
This also worked for me, although my project didn't have any settings.json file, so created one. Thanks
This no longer works (at least for me)
Where is the Settings.json file ?
|
119

I'm using tailwindcss in a react app. Tailwindcss Intellisense plugin was not working in my VSCode but then i installed HTML CSS Support extension and now i am getting suggestions of classes.

HTML CSS Support

enter image description here

5 Comments

May I ask if anyone knows why this works? 🤔 (Yes, it worked for me too. Thank you @Ahmad!)
I had to upgrade vscode version first, then this worked.
it worked though I had uninstall and reinstall this HTML CSS Support plugin. Odd.
This does not include the new colors and other utilities that can be generated by a custom TailwindCSS configuration. The official extension automatically builds all of these by interpreting the configuration of the given project: stackoverflow.com/a/79808707/15167500
I had this extension installed already, but after disabling it, the Tailwind extension is working again
71

What helped me was to check whether the plugin had any issue loading. You can do this by checking the output view:

  • CTRL + SHIFT + P to bring up the command palette
  • Search for "Output: Focus on Output View" enter image description here
  • In the Output View, search for tailwindcss-intellisense enter image description here

For me the error was Failed to initialise: ReferenceError: defaultTheme is not defined - I was missing a require for the defaultTheme.

12 Comments

I searched tailwind intellisense in extention, then I found Tailwind CSS IntelliSense (bradlc.vscode-tailwindcss), so I installed that. Thanks to this thread!
Thank you, I had my output hidden, this showed me to my issue.
THIS! Thank you. I deleted the last script in package.json and didn't remove the trailing comma. oops.
Answers like this one really upgrade you. It helps you debug the problem and help solving the problem in your own ways. In my case, I have to install linktailwindcss via npm. I was using tailwindcss directly with npx and it looks like intellisense extension require npm install.
This helped me as the output indicated an error that was easily corrected — it couldn't find the tailwind.config.js file.
|
65

To fix this issue try using ctrl + space

This is the easiest way I found to get Tailwind IntelliSense to work with .js files to React. You need to do this every time you are adding a new class but it's quicker than checking the documentation every time.

Credit: Reddit

2 Comments

How to do this in macbook?
This shortcut is occupied on Macs by default. You can free it up by navigating to System Preferences -> Keyboard -> Shortcuts -> Input Sources and removing both check boxes
18

if you're using nuxt/tailwind module be sure to init tailwind.config.js as doc says.

npx tailwindcss init

then restart the vs-code. it should automatically be active.

3 Comments

This was what worked for me. I only had a tailwind.config.ts file but this added the .js one and it now works.
why doesn't ts files work?
If the configuration file is located in a non-standard location, or if in v4 you want to use it without a tailwind.config.js, you may need to specify the correct path to the new CSS file - but you don't need an empty tailwind.config.js: stackoverflow.com/a/79808707/15167500 (second part)
16

Edit your VSCode settings.json:

"files.associations": {
  "*.css": "tailwindcss"
},
"editor.quickSuggestions": {
  "strings": true
}

Sometimes is needed to restart vscode.

Comments

12

for me..

I installed 'IntelliSense for CSS class names in HTML', 'HTML CSS Support', 'CSS Peek' all together with reinstalling..

It works now.

2 Comments

I did this, but didn't reinstall or reload. It worked!
This one worked for me (using CRA and Typescript), I have no idea why
12

To anyone still facing this problem, I found that the tailwind extension doesn't recognize your tailwind.config.js file if it's untracked (not added to source control). Once I added the file and did git commit, the extension worked.

2 Comments

For quick tests, I usually use the CDN version, so I don't really need the tailwind.config.js, but it seems the extension doesn't work without it.
Weirdly, worked like a charm.
11

Just go to the Tailwind CSS IntelliSense extension in Vs code and install the old version and reload it. It works. enter image description here

3 Comments

For the older version ,toggle the uninstall option and choose the 2nd option. ( I installed version 0.7.5)
yes is working, but can you tell me why the newer version doesn't work anymore? thanks for the answer
i had to install PostCSS Language Support extension to stop the warnings
10

I'm using tailwind + create-react-app + typescript, I solved it by changing the extension setting "Tailwind CSS: Include Languages", to {"plaintext": "ts"}.

I don't know why it didn't work in the first place, it was working for my other projects.

enter image description here

2 Comments

thanks, this work for me (tailwind, cra, typescript); to restart vscode use cntrl + shift + p > Developer: Reload Windows
Thanks, I was trying to get it working with JSP files. I had to go to this setting and add item: jsp, value: html. Then it sprang into life.
6

For React project with .tsx file, adding this works for me.

// .vscode/settings.json

{
  "tailwindCSS.includeLanguages": {
    "typescriptreact": "html"
  }
}

Credit: https://github.com/tailwindlabs/tailwindcss-intellisense/issues/72#issuecomment-674386396

Comments

4

I am using Tailwindcss with Django.
Facing the same issue where Tailwindcss IntelliSense plugin is already installed and autocomplete wasn't working.

Finally I got the perfect solution.

For most projects (and to take advantage of Tailwind’s customization features), you’ll want to install Tailwind and its peer-dependencies via npm.

npm install -D tailwindcss@latest postcss@latest autoprefixer@latest

In my case the postcss and autoprefixer was not installed.
You can run the above command and npm will take care of it if you have Tailwindcss already installed.

Also don't forget to put these lines in your settings.json in VSCode (Recommended VS Code Settings for Tailwind CSS IntelliSense):

// VS Code has built-in CSS validation which may display errors when using Tailwind-specific syntax, such as @apply. You can disable this with the css.validate setting

"css.validate": false,

// 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": true
},

// This setting allows you to add additional language support. The key of each entry is the new language ID and the value is any one of the extensions built-in languages, depending on how you want the new language to be treated (e.g. html, css, or javascript):
    
"tailwindCSS.includeLanguages": {
     "plaintext": "django-html"
},

Comments

4

I'm Using React via Vite, I just installed the Tailwind CSS IntelliSense extension and added this to my vscode settings.json to make it suggest strings:

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

Comments

3

This is the solution for autosuggestion on typing. So you don't need to use space+ctrl or just space. In case anyone needs it.

editor.suggest.snippetsPreventQuickSuggestions: false

Comments

2

Without pressing ctrl-space, I just need to press space and the classes will come out.

Comments

2

This setting is good working for react.js application

{
    "tailwindCSS.experimental.classRegex": [
        "class:\\s*\"([^\"]*)\""
    ],
    "emmet.triggerExpansionOnTab": true,
    "tailwindCSS.emmetCompletions": true,
   
    "editor.quickSuggestions": {
        "strings": true
    }
}

1 Comment

Thanks! Did did the trick for me in my Next.js project!
2

Running Tailwind CSS: Show Output from View -> Command Palette (or Ctrl + Shift + P), as suggested here, unveils that the "Tailwind CSS IntelliSense" plugin is looking for a proper npm installation of the module tailwindcss.

Solution: We can therefore fix the issue by simply running

npm install tailwindcss

within our project directory.

Comments

2

The extension HTML CSS Support extension is not the correct way to go. As specified in the official installation section of the detail page in the extension page in VSC.

In order for the extension to activate you must have tailwindcss installed and a Tailwind config file named tailwind.config.js or tailwind.config.cjs in your workspace.

so adding a file (even empty) named tailwind.config.js or tailwind.config.cjs at the root of your app will make it work.

2 Comments

In order for the extension to activate you must have tailwindcss installed and a Tailwind config file named tailwind.config.{js,cjs,mjs,ts} in your workspace.
2

I disabled and re-enabled the plugin. Wait a bit for it to re-indexing. And it works.

Comments

1

for me helps installed plugin IntelliSense for CSS class names in HTML

1 Comment

Please adda link to the extension: marketplace.visualstudio.com/…
1

I fixed it by creating a tailwind.config.js file with the help of npx tailwindcss init command. I was following tutorials of net ninja (youtube channel) and he mentioned this solution.

1 Comment

If the configuration file is located in a non-standard location, or if in v4 you want to use it without a tailwind.config.js, you may need to specify the correct path to the new CSS file - but you don't need an empty tailwind.config.js: stackoverflow.com/a/79808707/15167500 (second part)
1

If you are using tailwind with react, typescript, javascript, styled-components, and twin-macro, you have to add classRegEx manually to get the IntelliSense

To achieve this edit the user settings as below

 "tailwindCSS.experimental.classRegex": [
    "tw`([^`]*)",
    ["classnames\\(([^)]*)\\)", "'([^']*)'"]
  ],

For more information and to see what classRegEx should use with other techs read this

Comments

1

At first, write in your project npm install tailwindcss postcss-cli autoprefixer, Then write in your terminal npx tailwind init, at last write npm tailwind"postcss.config.js and then write in the file:

module.export = { plugins: [require('tailwindcss'), require('autoprefixer')]}; 

last step u can build your tailwindcss in packagein accordance with the package.json.

For more info u can visited this link.

1 Comment

If the configuration file is located in a non-standard location, or if in v4 you want to use it without a tailwind.config.js, you may need to specify the correct path to the new CSS file - but you don't need an empty tailwind.config.js: stackoverflow.com/a/79808707/15167500 (second part)
1

Make sure that you open the project from its root folder. I happened to me that there were multiple package.json files in the a different folder, the VS code plugin will be confused with tailwindcss path.

Just open the Explorer view and you should see one and only one package.json file and tailwindcss is listed as the dependencies.

Comments

1

How to get it working with denoland's Fresh framework

Check that the extension is not loading by opening the OUTPUT tab of the console and verifying that the dropdown menu has an entry for Tailwind CSS IntelliSense.

If it does not figure there you need to make a blank tailwind.config.js file at the root directory. This file is completely redundant with Deno, but required by the extension.


If it still does not help, try other methods shown in this thread. With the extension loading latest version of it does work on with setup.

Comments

1

According to the Troubleshooting section of https://github.com/tailwindlabs/tailwindcss-intellisense:

Make sure your VS Code settings aren’t causing your Tailwind config file to be hidden/ignored, for example via the files.exclude or files.watcherExclude settings.

This solved the issue for me.

Comments

1

I tried most of the solution but what worked for me is this , just copy past the following , you can remove the iconthem if you want .

{
    "tailwindCSS.includeLanguages": {
        "html": "html",
        "javascript": "javascript",
        "css": "css"
    },
    "css.validate": false,
    "workbench.iconTheme": "file-icons-mac",
    "tailwindCSS.emmetCompletions": true,
    "editor.inlineSuggest.enabled": true,
    "editor.quickSuggestions": {
        "strings": true
    }


}

Comments

1

You can check your vscode extensions if tailwind was enabled.

Due to some settings on my vscode i realised tailwind intellisence was disabled. Had to enabled it and that fixed the problem.

Comments

1

IF USING TYPESCRIPT

In my case, there was a linting error in my tailwind.config.ts file which for some reason was the cause. Clear out any linting errors and it should working again. Goodluck!

Comments

1

If you are working on react app, you need to create tailwind config file in your root directory as tailwind.config.js and add following content and then restart your VS code, it will work.

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.