Skip to content

Instantly share code, notes, and snippets.

@Chris-Gillis
Last active February 23, 2024 02:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Chris-Gillis/f04416d8179114f666b002c146c6f379 to your computer and use it in GitHub Desktop.
Save Chris-Gillis/f04416d8179114f666b002c146c6f379 to your computer and use it in GitHub Desktop.
Visual Studio Code config to get TailwindCSS autocomplete in Gomponents classes
import (
. "github.com/maragudk/gomponents/html"
)
func HeaderView() g.Node {
component := Div(Class("/* inside here you get tailwind autocomplete */"))
return component
}
{
"tailwindCSS.includeLanguages": {
"go": "html",
},
"tailwindCSS.experimental.classRegex": [
"Class\\(\"([\\w\\s\\-\\/]*)\"\\)"
],
}
@efosao
Copy link

efosao commented Feb 23, 2024

Thanks for posting this!!

I've updated it a bit to allow for:

  1. Semicolons in classes like e.g. hover:bg-white.
  2. Square brackets in custom classes e.g. w-[100px].
  3. The Gomponents Classes utility which takes a classes string and boolean e.g. c.Classes{"bg-red-200": isError},
"tailwindCSS.experimental.classRegex": [
    "Class\\(\"([\\w\\s\\-\\:\\[\\]/]*)\"\\)",
    "Classes\\{\"([\\w\\s\\-\\:\\[\\]/]*)\":(.)*\\}"
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment