Apply CSS tweaks only when dark theme is selected?

Solved

Hi guys, I'm wondering if there's a way to apply certain CSS tweaks only when I'm using the built-in dark theme.

For instance, let's say I'm using this to color the tabs &urlbar text white for better contrast against dark tabs:

:root {
  --chrome-color: #fff !important; 
}

Obviously the issue is that when I switch to the light theme I get white text against light grey background, which becomes hard to read. So is there something I can to do make sure that this tweak is only applied when the default dark theme is selected?

Posted Dec 7, 2017, 6:12 PM UTC

48
marciiF•
:root:-moz-lwtheme-brighttext {
    --chrome-color: #fff !important; 
}
3
bleeps__OP•

That works perfectly, thanks! Also with :root:-moz-lwtheme-darktext { for the light theme.

3
throwaway_3r•

If you want to do more complex stuff, you might want to try #main-window[lwthemetextcolor=dark] (for Light theme) or #main-window[lwthemetextcolor=bright] (for Dark theme).

/* Should hide the back button on the dark theme */
#main-window[lwthemetextcolor=bright] #back-button {
  display: none;
}
3
bleeps__OP•

This is probably going to be useful too, thanks!

2
poorman3333transform:•

Thanks!

2
fatihcoskuny•

CSS does not support conditional changes, but I guess you can use classes for it.

1
bleeps__OP•

I'll have a look at this, thanks!

2
Odinos•

In fact it does my friend

2