How to get the vscode theme color in vscode extensions?

拥有回忆 提交于 2019-12-12 14:51:05

问题


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.


回答1:


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




回答2:


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




回答3:


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)


来源:https://stackoverflow.com/questions/47117621/how-to-get-the-vscode-theme-color-in-vscode-extensions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!