46

I am unable to see the output on the display due to this problem. How can I fix this issue? I have already spent a lot of time trying to solve it, so can anyone provide a solution?

@tailwind base;       /* here */
@tailwind components; /* here */
@tailwind utilities;  /* here */

Unknown at rule @tailwind css(unknownAtRules)

tailwind rule error

7 Answers 7

108

You could look at installing the Tailwind CSS IntelliSense VSCode plugin and then:

files.associations

Use the files.associations setting to tell VS Code to always open .css files in Tailwind CSS mode:

"files.associations": {
  "*.css": "tailwindcss"
}

Otherwise, you could set css.lint.unknownAtRules VSCode setting to ignore.

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

9 Comments

I added the 'Tailwind CSS IntelliSense VSCode plugin' yet the warning persisted. Adding the file.association solved it. Thanks.
Adding files.associations solution works. Thank you
Where to add "files.associations" setting?
It's inside Preferences: Open Settings (UI)
In the appropriate VSCode settings JSON file.
Thank you this helped me on my Windows machine. Funny enough this did not happen on my Mac.
|
31

In Vs code just go in the extension tab and search for "Postcss language Support" and install the below extension> And after that the warning will be gone.

Install the below extension

enter image description here

Comments

25

One way to ignore the warning is to change file format from CSS to tailwindcss from vscode as follows:

On the bottom right of your vscode, select the 2nd or 3rd option based on extions your vs code's settings in order to change the file format.

Note: You may have to first install 'Tailwind CSS' extension.

Update filw mode

3 Comments

What is the command to change file format?
On the bottom right of your vscode, select the 2nd or 3rd option based on extions your vs code's settings in order to change the file format
For me, I was missing tailwindcss. A simple reinstall of the Tailwind CSS extension made it appear back in the language options.
2

for my case tailwind does not work but when i switch from :

module.exports  = {
  content: [".src/**/*.{html,js,ts,jsx,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}

to

export default {
  content: ["./src/**/*.{html,js,ts,jsx,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}

it work but the highlight still exist

2 Comments

And I assume you're using the extension mentioned earlier, which detected this configuration file up to v3. By the way, starting from v4, the @tailwind directive has been deprecated.
0

Putting my two cents in on this. In my existing React/Typescript/PostCSS project, I added the latest tailwind version. Also ran into the same unknown at rule warning. I did set the files.association bit which seems to solve the warning. However, now all my css files miss syntax highlighting. For info: I already have the Intellisense VSC addon installed earlier.

So.. how to get the color syntax back?

2 Comments

Hmz, I saw at the right bottom of VSC Plain text. Changed that to CSS and got the syntax back. Also, the website seems to still be fine. Perhaps it was a simple case of caching..
To soon: when adding a tailwind class, this doesn't show up.. weird thing.
0

In v4 you import Tailwind using a regular CSS @import statement, not using the @tailwind directives you used in v3: @import "tailwindcss";

Comments

-2

try this@import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities';

1 Comment

Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?

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.