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
docs(installation): add documentation for intellisense on SFC objects #382
Conversation
Added documentation and examples for enabling tailwind intellisense on objects in a vue SFC using a /*tw*/ prefix.
✅ Live Preview ready!
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the ui
prefix?
UI would make sense too. Would it make sense for tailwind intellisense on all SFC globally without syntactic sugar? Let me know and I can change the prefix to |
You can change to |
Awesome. I changed to
An example: <script setup>
const ui = /*ui*/ {
"base": "flex",
"background": `bg-gray-900`,
"heading": {
"background": 'bg-gray-700'
},
"footer": {
"background": 'bg-gray-700'
}
}
</script> |
Hello does it work if the hint is on top of the statement? this is the normal way of declaring annotations and would be nice if this is supported as otherwise maybe a bit counter intuitive <script setup>
// Will this work?
/*ui*/
const ui = {
"background": "bg-blue-500"
}
</script> |
Would this way interfere with JSDoc annotations? |
This works for declaring your annotation on top of the object declaration. It relies on a Let me know what you guys think! |
@MadDog4533 JSDoc syntax starts with a slash followed by two stars to be unique so that shouldn't be a problem // JSDoc starts with a '/**'
/**
* Represents a book.
* @constructor
*/
function Book(title, author) {
}
// Your descrimniator starts with '/*', we should be good!
/*ui*/
const ui = {
"background": "bg-blue-500"
} |
Added documentation and examples for enabling tailwind IntelliSense on objects in a vue SFC using a
/*tw*/
prefix.Sometimes when overriding too many ui props, a single line can get cluttered.
This would allow you to define your ui overrides in the
script
portion of the VUE SFC with IntelliSense.You would define the RegExp in
settings.json
with:"tailwindCSS.experimental.classRegex": [["/\\*tw\\*/\\s*{([^}]*)}", "'([^']*)'"]]
This can be appended to the ui config regexp that is already defined in the installation documentation.
How it works is it looks for JS objects prefixed with a
/*tw*/
comment.You could enable IntelliSense for the entire SFC but I figured
/*tw*/
would be better to avoid over-saturating editor suggestions.Here is an example:
You can also make it reactive with:
Hope this is useful!