0

Found this awesome post on how to dim semicolons in vscode.

Thinking it could be useful for javascriptreact and typescriptreact files to do the same for the className string when working with class utilities like tailwind.

Anybody knows a way to tackle this?


It would be icing on the top bonus if the rule could be ignored when j/tsx element it focused.

Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • find the TextMateScope of the element you want to change and modify your settings, there are enough posts here on SO to find out – rioV8 Dec 31 '21 at 17:04

3 Answers3

0

Continued to search SO after posting this (as suggested by @rioV8) and found this SO answer to lead me near the goal.

Installed the highlight extension and wrote this:

  "highlight.regexes": {
    "(.*\\sclassName=\")(.*?)\"": [
      {},
      {
        "color": "grey"
      }
    ]
  }

basic example

tailwind example

Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • had a couple of conflicting extensions that made it seem like it did not work at first, but it actually works quite well. – Norfeldt Dec 31 '21 at 19:29
0

Alternative (no extension needed) solution would be

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "string.quoted.double.tsx",
        "settings": {
          "foreground": "#ffffff77"
        }
      }
   ]

The problem is that it targets too wide and not just scoped to string.quoted.double.tsx within the className.

enter image description here

Norfeldt
  • 8,272
  • 23
  • 96
  • 152
0

Since I'm not the only one wanting a solution to the tailwind "noise" there is also an extension called "inline fold".

https://marketplace.visualstudio.com/items?itemName=moalamri.inline-fold

https://youtube.com/shorts/4VUaoUAaMQg?feature=share

Norfeldt
  • 8,272
  • 23
  • 96
  • 152