I want to be able to adjust my Firefox addon icon based on the theme being used in the browser. This seems pretty straight forward but must be able to handle 3 scenarios.
- Fully populated themes - Just grab “theme.colors.icons” and adjust your addon icon to match. (In my case, I am using a SVG and can just change the stroke to match the theme.
- Default themes (Light/Dark/Auto) - Will not have theme values, but can match “window.matchMedia(‘(prefers-color-scheme: dark)’)” to have a light vs. dark option.
- Partially populated themes - Some themes do not populate all values … especially “theme.colors.icons”. Can “try” to find similar values but this will be hit or miss as to how they look along side the theme. Could also just fall back to dark/light check if no theme.colors.icons.
In particular, I am a little surprised “Alpenglow Dark” properly returns theme.colors.icons, but “Firefox Alpenglow” does not. (Another strange thing is that the default Firefox icons are properly colored in both themes.)
Am I missing anything? (My addon is the “up arrow” in the toolbar)
Alpenglow Dark (Works great with theme.colors.icons)
Firefox Alpenglow
I used theme.colors.toolbar_text as an ALT here, but not a great fit. As you can see from the theme.colors … there are no other values with HSLA(271, 100%, 77%, 1) and theme.colors.icons is not being returned.



