The way I’m doing my themes are as follows.
I have 3 files.
- A general USS file that links all elements in my UI I would like themed (“ThemeElements.uss”).
- A “MyDarkTheme.uss” file that simply holds uss variables (see below for example).
- A Theme file (.TSS) that imports “ThemeElements.uss” and “MyDarkTheme.uss”.
In “ThemeElements.uss”, for example, I have my UI background selector set to a variable that each theme can use, and other common ui selectors that I want other themes to be able to override:
.theme_main__background {
background-color: var(--primary-color);
}
.theme_menu__border-color {
border-left-color: rgba(255, 255, 255, 0.5);
border-right-color: rgba(255, 255, 255, 0.5);
border-top-color: rgba(255, 255, 255, 0.5);
border-bottom-color: rgba(255, 255, 255, 0.5);
}
In “MyDarkTheme.uss” theme file, all I have are root variables to change the theme colors. So intead of duplicating all selectors in each theme file, I can just change the colors for each element I’ve created a variable for:
:root {
--primary-color: rgb(255, 255, 255);
--secondary-color: rgb(0, 0, 0);
}
But in some themes, I need to override other elements, like “.theme_menu__border-color” for example. Simply adding ".theme_menu__border-color { … } " to “MyDarkTheme.uss” file with different colors, doesn’t override that element.
So how would I override a selector that’s in another uss file?