-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocompletion Not Working with Vue.js and TailwindCSS v4 #1153
Comments
Same with Nuxt 3 and the Vite plugin, with CSS configuration instead of JS, intellisense not working |
noticed the same behaviour, its not just vue, its in astro, next and perhaps other too. I suspected it could be because of the missing tailwind.config file. just added a file my tailwind.config mjs like this since I am using astro /** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
} |
@rrobertobt @vikramsoni2 Nah, a config file is not necessary. Adding one kinda forces IntelliSense into a "fallback" mode where it's using an embedded version of Tailwind CSS v3.4. It also means it couldn't detect your Tailwind CSS v4 installation and/or your project's CSS file. Can you please provide reproductions? @ElvinKyungu Could you also provide a reproduction? |
I am experiencing this problem as well, when using bun in combination with bun-plugin-tailwind. It seems the matching code has not been updated in 6 months: This is where the output shown in VSCode comes from as well:
Seems like this and the troubleshooting guide on needs to be updated, since v4 is zero config? EDIT: Auto complete etc. works for me now, even without a tailwind config file. I tried reloading the window and looking through the output (Cmd/Ctrl + Shift + P > Tailwind CSS: Show output). Can you guys provide the information logged in the beginning, if you are still experiencing issues? |
Thanks a lot, @nimrossum i was searching again and again , and started doubting the installation method of tailwind v4, and but when i used tailwind class it works fine now. (Cmd/Ctrl + Shift + P > Tailwind CSS: Show output).
Problem: tailwind css intelliSense needs vscode window a reload, you done it with cmd ( Ctrl + Shift + P ) -> reload window Happy Coding Everyone |
I had a similar issue in both VS Code and Jetbrains products, but the problem was actually before this error. I was working in a Orchestra Testbench project, which has a symlink deep in the vendor folder back to the vendor folder in root of the project. The Tailwind Intellisense was getting stuck in a loop searching these directories and getting an error as below:
It showed the full, looping path it was trying to scan. Once it hit this error, it would get the "No matching project for document" error as other people have reported. I added |
@Smef 😱 we should definitely fix that. Do you happen to have a git repo already set up I can test with? (I can create a test bench project if needed — git repo would just be quicker) |
Here's a demo repo: https://github.com/Smef/tailwind-symlink-demo |
I'm not sure if it's already been mentioned, but I haven't found a solution for this. Intellisense works fine for utility classes in class attributes and with I use VSCode with IntelliSense v0.14.4 and have a styles.css configuration.
I installed Vue and Tailwind as follows:
The configuration in styles.css is minimal: @import "tailwindcss";
@theme {
--color-gold: #efbf04;
--color-silver: #c4c4c4;
}
@layer components {
.nice-layout {
@apply h-20 m-2 p-2 border-2 border-gray-400;
}
} In App.vue, <script setup lang="ts">
import { ref, computed } from 'vue';
const trigger = ref(true);
const myClasses = computed(() => {
return {
'text-xl': trigger,
}
})
</script>
<template>
<div class="nice-layout bg-gold" :class="myClasses">
You did it!
</div>
</template> @thecrypticace Is there already a more suitable ticket for this, or should I create a new one? |
You can use this but it's a bit brittle syntax-wise: "tailwindCSS.experimental.classRegex": [
["Classes\\s*=\\s*computed\\(\\(\\)\\s*=>\\s*([\\s\\S]+?)\\)", "'([^']+)'"],
], |
@thecrypticace Many thanks for your help, the RegEx works perfectly! To investigate the question of whether "it worked in v3", I created a VSCode profile for my mini-project and only installed the two extensions “Tailwind CSS IntelliSense” and “Vue - Official”. However, I tested with v4 and the latest version of Intellisense and not with v3. The settings.json is minimal: {
"files.associations": {
"*.css": "tailwindcss"
},
"tailwindCSS.experimental.classRegex": [
["Classes\\s*=\\s*computed\\(\\(\\)\\s*=>\\s*([\\s\\S]+?)\\)", "'([^']+)'"]
]
} As expected, Intellisense works in the class attribute and (now also😊) in the computed property, but not for the @import "tailwindcss";
@theme {
--color-gold: #efbf04;
--color-silver: #c4c4c4;
}
@utility nice-layout {
@apply h-20 m-2 p-2 border-2 border-gray-400;
} To strengthen my assumption that it already works in v3 with the components layer, I replaced the configuration in styles.css with a tailwind.config.ts. The tailwind.config.ts is loaded in styles.css: @import "tailwindcss";
@config "../tailwind.config.ts"; The tailwind.config.ts looks as follows: import type { Config } from "tailwindcss";
import plugin from "tailwindcss/plugin";
const config: Pick<Config, "content" | "theme" | "plugins"> = {
content: {
files: ["./index.html", "./src/**/*.{vue,js,ts}"],
},
theme: {
extend: {
colors: {
gold: "#efbf04",
silver: "#c4c4c4",
},
}
},
plugins: [
plugin(({ addComponents }) => {
addComponents({
".nice-layout": {
"@apply h-20 m-2 p-2 border-2 border-gray-400": {},
},
});
}),
],
};
export default config; Interestingly, if I now hover over
|
I would've expected you to test with v3 mainly because
Again, it wasn't supported before either (but There's two things here:
|
Further, things added in |
Yes, I would convert these to |
@thecrypticace You're right, the compatibility layer in v4 is obviously not the same as v3, therefore I tested again with tailwind version 3.4.17 and Tailwind CSS IntelliSense v0.10.5. The settings.json and tailwind.config.ts are the same as above. The hover now looks like this: And that is exactly how I know it from before. Because I want something similar for custom classes, I thought I would get that with |
So it's a convention but only so far as we have a dedicated spot for it by default so they appear before utilities. But you can "deconstruct" the imports for Tailwind CSS and name the layers anything you want: @layer john, paul, george /* this was components before */, ringo;
@import 'tailwindcss/theme.css' layer(john);
@import 'tailwindcss/preflight.css' layer(paul);
@import 'tailwindcss/utilities.css' layer(ringo);
@layer george {
.nice-layout {
margin: 0.5rem;
}
} Now, I don't recommend doing this (with picking odd layer names I mean) but you definitely can and IntelliSense doesn't care if you do. It's only ever been concerned with utilities and variants known to Tailwind CSS:
All of the features and suggestions are designed around that fact. There are assumptions that every class that we care about can have variants applied to it, that when we see something like I'm not necessarily opposed to adding this feature to IntelliSense but it's a bit more complicated of a task because of all of the assumptions we make about what classes we know about and which ones we don't. |
As an aside this issue has kinda derailed a bit. @ElvinKyungu I'm gonna close this one as no reproduction was provided. If you can provide a reproduction, please open a new issue. Thanks! |
Also @matthias-sms I've added the ability to suggest normal CSS classes to our backlog so I am going to look into it — I just don't necessarily expect to ship such a feature soon. |
@thecrypticace I apologize that the chat has drifted away from the original topic. The title triggered me and I didn't want to create a new ticket unnecessarily. Thank you very much for your support and your detailed answers.❤️ It has helped me a lot and improved my understanding of Tailwind and IntelliSense. |
all good! |
Description
The autocompletion for TailwindCSS classes is not working in my Vue.js project using TailwindCSS v4. This makes development less efficient and increases the chances of errors due to manual typing of CSS classes.
Steps to Reproduce
Initialize a Vue.js project with vite and install TailwindCSS v4.
Configure tailwind.config.js to include Vue files as templates.
Try using TailwindCSS classes in a .vue file.
Notice that autocompletion for TailwindCSS classes doesn’t work (neither in nor <script>).
Expected Behavior
TailwindCSS class autocompletion should work, suggesting valid classes and assisting in writing them.
Environment
IDE/Editor: Visual Studio Code
Installed Extensions:
Tailwind CSS IntelliSense v0.14.1
Vue.js Version: 3.5
TailwindCSS Version: 4.x
Build Tool: Vite
Additional Context
Verified that tailwind.config.js includes the correct paths for .vue files.
The Tailwind CSS IntelliSense extension is enabled and properly configured.
No error messages appear in the console.
Suggestions
If this issue is related to a specific configuration of TailwindCSS v4 or a conflict with Volar, providing clarification in the documentation or updating the extension could help resolve the problem.
The text was updated successfully, but these errors were encountered: