Tailwind CSS IntelliSens
#
Tailwind CSS IntelliSens
is a VSCode
plugin used for syntax hints and auto-completion. It is an essential plugin.
https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
The common issues encountered are listed as follows:
1. A space is needed to trigger auto-completion#
The following configuration in .vscode/settings.json
can solve this issue:
"editor.quickSuggestions": {
"strings": true
},
2. Customizing the trigger for auto-completion#
By default, the plugin triggers auto-completion when the user writes className=xxx
, but sometimes we encapsulate common className
s, for example, into a js
object. This can be resolved in settings.json
by configuring tailwindCSS.experimental.classRegex
:
"tailwindCSS.experimental.classRegex": [
["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*)[\"'`]"]
]
For more custom rules, please refer to: https://github.com/paolotiu/tailwind-intellisense-regex-list#classnames
The effect is as follows: