Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
Last active April 4, 2024 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuabaker/66615d45b32675e5109c61f204ccdc5a to your computer and use it in GitHub Desktop.
Save joshuabaker/66615d45b32675e5109c61f204ccdc5a to your computer and use it in GitHub Desktop.

Tailwind class autocomplete in object strings

Using Tailwind’s intellisense in VSCode and other IDEs, it’s possible to autocomplete classes in class, className, et al.

In some cases you want to introduce variants, which mean autocomplete is not available. To get around this, I use the following setup.

//                Add this to objects
//                ↓     ↓
const variants = /* tw */ {
  variant: "grid",
};
"tailwindCSS.experimental.classRegex" = [
  ["/\\*\\s*tw\\s*\\*/\\s*{([^}]*)}", "\"([^\"]*)\"|'([^']*)'"], // ← Add this
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment