Edit your settings.json as below:
{
// other settings
"tailwindCSS.includeLanguages": {
"javascript": "javascript",
"html": "HTML"
},
"editor.quickSuggestions": {
"strings": true
}
}
Answer from chankruze on Stack OverflowVS Code Extension for Formatting Tailwind Classes (JSX/TSX)
VSCode Tailwind Class Reorder Extension
Videos
Got into Tailwind last year when developing a personal project and ended up loving it, but disliked the utility class name bloat so I decided to make a VS Code formatter extension to prevent me from going insane. Hoping this helps anyone else out there with the same frustrations.
(Currently only JSX/TSX files supported, but I'm working on potential multi-language support for the next version. The code is open-source and can be found here: GitHub Repo)
Let me know if you find any bugs or issues. And if you liked the extension, please consider a rating/review, a star on the repo, or maybe even a sponsor :) or feel free to just share it around!
Tailwind Formatter Extension DemoExtension Link: https://marketplace.visualstudio.com/items?itemName=Myhtica.tailwind-formatter
Edit your settings.json as below:
{
// other settings
"tailwindCSS.includeLanguages": {
"javascript": "javascript",
"html": "HTML"
},
"editor.quickSuggestions": {
"strings": true
}
}
Here's how to get Tailwind Intellisense to work with React files
- Go to Tailwind CSS settings and add Javascript support
"tailwindCSS.includeLanguages": { "plaintext": "javascript" } - Reload vscode
If this doesn't fix things, try using ctrl + space before adding a class name.
View image of Tailwind settings
I like the work that the tailwind team did with the prettier plugin, but for reasons I am not able to use prettier in some of the projects I work on.
That being said, the class reordering feature is pretty much a must for being able to quickly see what classes are on an element at a glance and knowing which classes will override others. Bonuses for minification and compression wins.
I have forked an older VSCode extension that is seemingly no longer maintained and updated it to work in much the same way as the prettier plugin; except that it only rearranges classes and should not touch other parts of your code at all. I am currently using it in JS, TS, and PHP files without issue. Feel free to give it a try if you find yourself in a similar situation to myself.
Tailwind Raw Reorder Extension
edit: added link to post body