-1

As soon I installed the newer version of TailwindCSS V4.1 the autocomplete suggestion from Tailwind CSS IntelliSense donot work. So far I have tried the following troubleshooting methods:

  1. Adding experimental config on settings.json "tailwindCSS.experimental.configFile": "src/index.css"
  2. Adding old style empty tailwind.config.js file at the root folder.
  3. Tried disabling and enabling the Tailwind CSS IntelliSense.
  4. Adding space before each tailwind ClassName, for e.g " text-red-500"

All of the methods above had been done in isolation from each other, after each method the VS code has been restarted to test the implementation. The editor.quickSuggestions for the Strings is also turned on. I have made sure that there is no file from tailwind is being excluded in VS Code.

0

1 Answer 1

0

I see you're using the official TailwindCSS IntelliSense extension. By default, the extension only provides hints inside class="..." and className="..." attributes. However, this can be extended with additional attributes, functions, or even custom regex syntax.

Note: The example below is specifically tailored for the twrnc package, but of course, you can customize it for any of your own functions or attributes.

From TailwindCSS IntelliSense v0.14.10

For the TailwindCSS IntelliSense to work within the tw function added by twrnc, you need to add the function name to tailwindCSS.classFunctions, like this:

{
  "tailwindCSS.classFunctions": ["tw", "tw.style"]
}

Note: This only replaces classRegex; however, using classAttributes alongside it is still recommended.

This enables autocomplete in the tw("...") and tw.style("...") functions without using regex.

Until TailwindCSS IntelliSense v0.14.9

However, if you want it to work in the style attribute within an HTML structure, you need to add the following alongside the default class and className:

{
  "tailwindCSS.classAttributes": [
    // ...
    "style"
  ],
}

Additionally, you can use the classRegex expression you mentioned to declare the hint to be requested when calling the function, based on twrnc's recommendation:

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

The first enables autocomplete inside the style="..." attribute, and the second one is an older expression for enabling it within tw("...") and tw.style("...") functions as well.

Sign up to request clarification or add additional context in comments.

1 Comment

I am using by default className autocomplete suggestion, I have tried numerous attempts but no luck. Also, the tailwind code works only that auto suggestions part does not work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.