Replies: 31 comments 45 replies
-
Using
|
Beta Was this translation helpful? Give feedback.
-
For some reason this regex doesn't work {
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"tailwindCSS.experimental.classRegex": [
"classList={{([^}]+)}}"
]
} <button
class="p-2 border border-gray-200 rounded-md"
classList={{ 'p-4': isDark() }}
>
Lesson
</button> Then I had a thought that you can't intellisense object string keys, but you can using the class comment hack. So it is possible to intellisense object string keys. ```js
<button
class="p-2 border border-gray-200 rounded-md"
// class="
classList={{ 'p-4': isDark() }}
//"
>
Lesson
</button> So this regex should work as it does here https://regex101.com/r/5I3Fsb/1 |
Beta Was this translation helpful? Give feedback.
-
Hey @bradlc I'm getting the following error: Hovering, linting and autocompletion doesn't work for me. Does it have something to do with the limit? If so, can it be increased somehow?
|
Beta Was this translation helpful? Give feedback.
-
I'm using Tailwind classes as strings stored into a variable:
If you're using this convention, adding The settingWith the UIWith settings.jsonThe resultHope this helps! :) Edit: This approach also works with nested objects: |
Beta Was this translation helpful? Give feedback.
-
Quick question, any idea why code completion and hovering both work but linter does not? (have some typos in tailwind classes but the plugin can't detect them) changes to settings
|
Beta Was this translation helpful? Give feedback.
-
Hi, I just tried the
This works fine until I have a larger |
Beta Was this translation helpful? Give feedback.
-
For react components, this regex works for component names ending with |
Beta Was this translation helpful? Give feedback.
-
Just wanted to mention that for ruby / rails html.erb files the following configuration works. Locate the following configuration in Vscode: Press "tailwindCSS.experimental.classRegex": [
"class: ['\"](.+?)['\"]" // class: "..." // ruby .html.erb
], Editing any erb files should now result in the following looks: |
Beta Was this translation helpful? Give feedback.
-
I'm using it like this. IntelliSense works but auto-sorting does not. Does someone know why? {
"tailwindCSS.experimental.classRegex": [
"\\/\\*\\s?tw:\\s?\\*\\/\\s?`(.*)`"
]
} const classes = {
root: /*tw:*/ `group inline-flex flex-col`,
fullWidth: /*tw:*/ 'w-full',
label: /*tw:*/ `mb-2 text-white`,
}; |
Beta Was this translation helpful? Give feedback.
-
Hey, thought I would share this for those who end up here when looking for a Clojure or ClojureScript solution like I did. Some nice folks on the Clojure slack helped me find this full solution that gives you autocompletion using both styles of hiccup (eg.
|
Beta Was this translation helpful? Give feedback.
-
Here's my VS Code "tailwindCSS.experimental.classRegex": [
["Classes \\=([^;]*);", "'([^']*)'"],
["Classes \\=([^;]*);", "\"([^\"]*)\""],
["Classes \\=([^;]*);", "\\`([^\\`]*)\\`"]
], Tailwind IntelliSense will now recognize all of the following strings: const defaultClasses = `text-grey`;
const componentClasses = {
default: 'text-grey',
danger: `text-red`,
warning: "text-yellow",
}; Note: the regex matches code blocks that start with |
Beta Was this translation helpful? Give feedback.
-
Has anyone figured out a way to get the intellisense tooltips to display on tailwind classes in a TS variable? |
Beta Was this translation helpful? Give feedback.
-
Put together a few variations:
To make it easier when working with arbitrary value situations "tailwindCSS.experimental.classRegex": [
"\\/\\*\\s*tw\\s*\\*\\/\\s*[`'\"](.*)[`'\"];?",
["(?:twMerge|twJoin)\\(([^\\);]*)[\\);]", "[`'\"]([^'\"`,;]*)[`'\"]"],
"twc\\`(.*)\\`;?"
], |
Beta Was this translation helpful? Give feedback.
-
This will detect a container consisting of
|
Beta Was this translation helpful? Give feedback.
-
Can anyone confirm or deny that it is not possible to get the popover definition to display using any of these methods? |
Beta Was this translation helpful? Give feedback.
-
Extension development team should have official sample configs in the document to guide users to add autocomplete for packages like As it is now, everything is not clear |
Beta Was this translation helpful? Give feedback.
-
Hello everyone! Setting up regex for each library is hard, so I made a repository that tried to collect all the configs needed for intellisense to work. Right now it has most of the popular libraries handled, but I would love to add lots more! Link to repo: https://github.com/paolotiu/tailwind-intellisense-regex-list |
Beta Was this translation helpful? Give feedback.
-
Hello. I use Tailwind with sveltekit and created such regex for string completion:
Completion is works, but hovering info is not working in *.svelte files. In *.js is working. I missed something? |
Beta Was this translation helpful? Give feedback.
-
Hello; File association doesn't work every time. Weird thing, after added css and scss file associated to tailwind. What could be wrong ? |
Beta Was this translation helpful? Give feedback.
-
Has anyone managed to get this working with function args. I'm particularly looking for |
Beta Was this translation helpful? Give feedback.
-
Whatever you end up doing, it would be amazing if Prettier was able to pick up on the same pattern! I am using "tailwindCSS.experimental.classRegex": ["*className"] It works perfectly with the IntelliSense plugin (both for constants in files as well as component attributes) but doesn't get formatted by Prettier. |
Beta Was this translation helpful? Give feedback.
-
For svelte users, "tailwindCSS.experimental.classRegex": [
"class:(.+)"
] |
Beta Was this translation helpful? Give feedback.
-
Want to point out you can use this as guide to create your custom regex: https://github.com/paolotiu/tailwind-intellisense-regex-list |
Beta Was this translation helpful? Give feedback.
-
Any reason this is not documented in the README? It took me some time to end up here 😅 |
Beta Was this translation helpful? Give feedback.
-
For those who use Webstorm, this worked for me. Go to: Setting > Languages & Frameworks > Style Sheets > Tailwind CSS At the bottom of the JSON configuration, you can add the regex {
//...
"experimental": {
"classRegex": ["composes: ([^;]*)"]
}
} |
Beta Was this translation helpful? Give feedback.
-
The official plugin Actually this is very helpful because in general function calls are not parsable using regular expressions, JS being an irregular language. It covers template literals as well (which are functions). This is very easy in prettier where an AST is already present, but is such a thing impossible in this plugin? |
Beta Was this translation helpful? Give feedback.
-
{
"tailwindCSS.experimental.classRegex": [
// Outer selector tw() - Inner selector '' or "" or ``
["tw\\(([^)]*)\\)", "(?:')([^']*)(?:')"],
["tw\\(([^)]*)\\)", "(?:\")([^\"]*)(?:\")"],
["tw\\(([^)]*)\\)", "(?:`)([^`]*)(?:`)"]
],
}
/**
Use tailwind intellisense
see: `.vscode\settings.json`
regex defined by `tailwindCSS.experimental.classRegex`
should match the literal string argument passed to this function.
@returns the argument as is.
*/
export const tw = <T extends string>(classes: T) => classes;
{
"plugins": ["prettier-plugin-tailwindcss"],
"tailwindFunctions": ["tw"]
}
{
"devDependencies": {
"prettier-plugin-tailwindcss": "latest",
}
} This setup works great. Hope this helps anyone |
Beta Was this translation helpful? Give feedback.
-
Hi, I’m using CDN to include Tailwind CSS in HTML, but I’m facing an issue with the lack of IntelliSense in VSCode. I’ve configured tailwind.config.js, which enables IntelliSense in |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Trying to get intellisense to work with element.className Has anyone ran into this issue and had success in finding a solution? |
Beta Was this translation helpful? Give feedback.
-
There has been quite a few requests for the extension to support class name completions in contexts other than a standard class(Name) attribute.
Some examples:
tailwind.macro
andtwin.macro
(Add scrolling-touch/auto docs #46, Support for tailwind.macro in styled/emotion like tw...
or tw.div...
tailwindcss-intellisense#123):tailwind-rn
(Add@important
at-rule #99):tailwind-ppx
(Algolia's DocSearch ready! ✨ #120):I just wanted to consolidate all of these requests into a single issue that can be tracked more easily, as I think the solution could be the same for each of them.
I am reluctant to hard-code each of these cases into the extension because none of them are "official" methods of using Tailwind, and it may become a maintenance burden.
However, I am open to the idea of adding a user setting which would allow the definition of custom regular expressions. For example for
tailwind-rn
your regular expression might be something like:/\btailwind\([^)]+/ig
If you're interested in this feature feel free to "watch" this issue for updates, and post any comments/suggestions you may have.
Beta Was this translation helpful? Give feedback.
All reactions