Replies: 35 comments 50 replies
|
Using |
|
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 |
|
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?
|
|
I'm using Tailwind classes as strings stored into a variable: const baseStyles = 'bg-green-700 text-white'If you're using this convention, adding The settingWith the UIWith settings.jsonThe resultHope this helps! :) Edit: This approach also works with nested objects: |
|
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 |
|
Hi, I just tried the This works fine until I have a larger |
|
For react components, this regex works for component names ending with |
|
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: |
|
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`,
}; |
|
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. |
|
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 |
|
Has anyone figured out a way to get the intellisense tooltips to display on tailwind classes in a TS variable? |
|
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\\`(.*)\\`;?"
], |
|
This will detect a container consisting of
|
|
Can anyone confirm or deny that it is not possible to get the popover definition to display using any of these methods? |
|
Has anyone managed to get this working with function args. I'm particularly looking for |
|
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. |
|
Want to point out you can use this as guide to create your custom regex: https://github.com/paolotiu/tailwind-intellisense-regex-list |
|
Any reason this is not documented in the README? It took me some time to end up here 😅 |
|
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: ([^;]*)"]
}
} |
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? |
|
{
"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 |
|
this is my setting it can easy change const g = {
d: clsx("match ", { d: "match " }, "match "),
dd: "not-match ",
};
const dClasses4 = "not-match ";
const dStyle = "match ";
const gStyle = {
d: clsx("match", { d: "match" }),
dd: "match",
};
const dClasses = "not-match ";
const dClasses2 = clsx("match ", "match", { d: "match" });
const dClasses = "not-match "; "tailwindCSS.experimental.classRegex": [
["Style\\s*=\\s*{(.*)};", ": \"([^\"]*)\""],
["Style\\s*=\\s*{([\\s\\S]*)};", "\\s*['\"`]([^'\"`]*)['\"`]"],
"Style\\s*=\\s*['\"`]([^'\"`]*)['\"`];",
["clsx\\(([^)]*)\\)", "\"([^\"]*)\""]
] |
|
{
"tailwindCSS.experimental.classRegex": [
["(?:class|className|class-name)\\s*=\\s*\"([^\"]*)\"", 1],
["(?:class|className|class-name)\\s*=\\s*`([^`]*)`", 1],
["tw\\(([^)]*)\\)", 1]
],
}it work's for <CustomDevOnly className="fixed top-4">
{{ ... }}}
</CustomDevOnly>and won't work for this one <CustomDevOnly class-name="fixed top-4">
{{ ... }}}
</CustomDevOnly> |
|
Hi, does anybody use the language server via Zed and with Ruby? Relevant part of "lsp": {
"tailwindcss-language-server": {
"settings": {
"includeLanguages": {
"ruby": "html",
},
"experimental": {
"classRegex": [
"\\bclass:\\s*%w\\[\\s*([^\\]]*)\\s*\\]", // <- this does not work
"\\bclass:\\s*['\"]([^'\"]*)['\"]",
],
},
},
},
},The regular expression should be good (https://regex101.com/r/Q6pObz/1), but still, intellisense works only within strings. Thanks! |



















Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.macroandtwin.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@importantat-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-rnyour regular expression might be something like:/\btailwind\([^)]+/igIf you're interested in this feature feel free to "watch" this issue for updates, and post any comments/suggestions you may have.
All reactions