how to bring the vscode css color picker feature into js file with string that match color name format? how to bring the vscode css color picker feature into js file with string that match color name format? javascript javascript

how to bring the vscode css color picker feature into js file with string that match color name format?


I found colorize which can highlight JavaScript and TypeScript (among others) GitHub

In your settings.json in VSCode just add languages you'd like to target:

"colorize.languages": ["typescript", "javascript", "css", "scss"]

enter image description here


To anyone who uses Colorize and wants it to work on their React project (css in js and such):

use

"colorize.languages": ["javascriptreact", "javascript", "css", "scss"]

as apparently "javascriptreact" is needed and not "javascript"


There is one possible implementation with vscode-color-info from wayncheng

Adding the following code to colorInfo.languages in settings.json should do the trick. Make sure to include all the default languages as well so they aren't disabled.

{    "selector": "javascript",    "colors": "css"}

So your settings.json should look something like this:

"colorInfo.languages": [    {        "selector": "css",        "colors": "css"    },    {        "selector": "sass",        "colors": "css"    },    {        "selector": "scss",        "colors": "css"    },    {        "selector": "less",        "colors": "css"    },    {        "selector": "html",        "colors": "css"    },    {        "selector": "javascript",        "colors": "css"    }]