How to get the vscode theme color in vscode extensions?

Viewed 3885

I want to use some color used in current vscode theme in my extension. How do I get the colors?

In other words, I want to match the color of extension using original color with the base vscode windows in run-time of extension.

3 Answers

For accessing the theme color on the WebView context, there are css variables generated for all the theme colors. For example, for getting:

editor.background

You can use the css variable:

var(--vscode-editor-background)

When you have your desired color scheme in your VS Code instance, run the Developer: Generate Color Theme From Current Settings command. This will generate a color theme file that you can then publish in your own extension

Related