Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add color to component tags in Visual Studio Code?

I am learning React, and I observe some people made the color of Component tags different from normal HTML tags under JSX format. However I am not really able to find extensions that do this (tried prettier and react snippets etc.). I wonder what enables that behavior?

enter image description here

like image 777
Dave Yu Avatar asked Sep 11 '25 12:09

Dave Yu


2 Answers

In "settings.json":

"textMateRules": [
    {
        "name": "component tags",
        "scope": [
            "entity.name.tag", // HTML tags
            "support.class.component", // JSX/TSX Component tags
        ],
        "settings": {
            "foreground": "red",
        }
    }
like image 173
Elect2 Avatar answered Sep 13 '25 02:09

Elect2


All you have to do go to C:/->Users->"Your Username"-> .vscode->extensions and in there open the monokai pro folder, go into "themes", and edit the monokai pro json file in vscode or another suitable editor.

Using the token inspector tool I searched up the scope of the JSX custom components which is "entity.name.tag support.class.component" and then made a new rule object separating regular "entity.name.tag" which are the built-in HTML elements from the react custom components. And made the color a nice greeny aqua (See the edited JSON file below)

The edited json picture

like image 40
Sisay Kewiti Avatar answered Sep 13 '25 04:09

Sisay Kewiti