Themes class
The IDE’s active-theme state — reached through Host.Themes. Pair with the Host.OnChangedTheme event to refresh any colour-sensitive elements the addin draws inside its tool windows.
Private Sub Host_OnProjectLoaded()
ApplyThemeColors ' set initial colours based on the current theme
End Sub
Private Sub Host_OnChangedTheme(ByVal ThemeName As String)
ApplyThemeColors ' user picked a new theme — re-apply
End Sub
Private Sub ApplyThemeColors()
Select Case Host.Themes.ActiveThemeNameGroup
Case "dark": myToolWindow.ApplyCss "body { background: #1e1e1e; color: white; }"
Case "light": myToolWindow.ApplyCss "body { background: white; color: black; }"
End Select
End Sub
Properties
ActiveThemeName
The name of the current IDE theme — e.g. "Classic", "Dark", "Light". String, read-only.
The set of available themes is determined by the IDE and may grow in future versions; do not switch on this value with an exhaustive Select Case. For binary light-vs-dark colour decisions, use ActiveThemeNameGroup instead.
ActiveThemeNameGroup
The high-level “family” the current theme belongs to. String, read-only — exactly "dark" or "light".
Useful for an addin that wants to flip its own colours between dark-on-light and light-on-dark without parsing ActiveThemeName.
Colours for addins
Each theme has eight colours for what an addin draws in its tool windows and its designers. The IDE gives each to the addin’s CSS as a variable named --theme followed by the theme property’s name, as it does for every property of a theme. So a designer whose style sheet uses the variables follows the IDE’s theme with no code in the addin, and a datasheet draws itself in them:
myToolWindow.ApplyCss _
"#panel { background: var(--themeAddinPanelBackColor, #2b2e40);" & _
" color: var(--themeAddinForeColor, #eeeeee);" & _
" border: 1px solid var(--themeAddinBorderColor, #454a60); }"
Give each var() a second value, as here, for an IDE whose theme does not set the colour.
A ToolWindow follows a change of the theme as a designer does: when the user chooses another theme, its variables take the new theme’s values, and what is drawn with them, a datasheet included, changes with them.
| Variable | For | Dark | Light |
|---|---|---|---|
--themeAddinBackColor | The background of the whole window or designer. | #2b2b2b | #FFFFFF |
--themeAddinPanelBackColor | The background of a panel inside it, such as a header or a toolbar. | #494343 | #F0F0F0 |
--themeAddinControlBackColor | The background of a control: a button, a text box, a list. | #575050 | #E1E4E6 |
--themeAddinBorderColor | Borders and dividing lines. | #666060 | #C3CDDA |
--themeAddinForeColor | Text. | #eeeeee | #20232B |
--themeAddinSecondaryForeColor | Text of less weight, such as a hint or a count. | #BCB5B5 | #606A79 |
--themeAddinAccentBackColor | The background of what stands out: a selection, the default button. | #AC947A | #3E6FC1 |
--themeAddinAccentForeColor | Text on the accent background. | #1F1B18 | #FFFFFF |
A theme of your own can set them as AddinBackColor and the rest; see Themes.