Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the vscode theme color in vscode extensions?

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.

like image 828
henoc Avatar asked Dec 03 '22 21:12

henoc


2 Answers

You can reference workbench colors:

const color = new vscode.ThemeColor('badge.background');

That will give you reference to the color of the current theme's badge.

Note, that you cannot reference TM scope items: #32813

https://code.visualstudio.com/docs/extensionAPI/vscode-api#_a-namethemecoloraspan-classcodeitem-id244themecolorspan

like image 116
Alex Avatar answered Dec 28 '22 09:12

Alex


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)
like image 23
idanp Avatar answered Dec 28 '22 09:12

idanp