browserAction.setIcon feature parity with browser_action.theme_icon

webextensions-api
(Jeremiah Lee) #1

In a WebExtensions manifest.json, browser_action.theme_icon can be used to specify light and dark theme icons for the browser action button.

However, there does not seem to be a way to provide a theme-aware icon set when changing the browser action button’s icon using browserAction.setIcon().

Ideally, I would be able to pass the same theme_icon object type used in the manifest.json to browserAction.setIcon() and have the browser pick the new theme-appropriate icon in the same manner as it did determining the initial icon from the manifest file.

My use case: I want my browser action button icon to indicate a state of my extension and I want the icon to be appropriate in both light and dark themes.

Any ideas or suggestions on how to achieve this?

(Martin Giger) #2

You can try using theme.getCurrent() however I think that still doesn’t properly cover all cases. Best practice used to be to give a choice to the user to toggle what variant they prefer. Adapting icons to theme colors is still very much unsolved in extensions (this includes other icon usages).

(Jeremiah Lee) #3

Thanks for the answer! That’s an unfortunate situation. I feel making someone pick their OS theme, then pick their browser theme, then individual buttons in the browser is a bit of an overload. Hopefully this will improve at some point. Sorry for now, dark-theme friends.