-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensions API to query the current browser theme #680
Comments
CSS technically has the ability to use the OS color, but these keywords have been broken for a long time (or maybe they only worked in IE) https://developer.mozilla.org/en-US/docs/Web/CSS/system-color I think supporting this would go a long way, but unfortunately it doesn't work: background-color: Canvas;
color: CanvasText; My use case would be to make my sidePanel extension blend in with the browser. |
@fregante, what browsers do the systems styles not work in? I tested that CSS snippet a few months ago in Firefox and it worked as expected. |
They "work" by changing the color, but they "don't work" because the color doesn't actually match the browser's theme. Here's Firefox and Chrome. To be fair even Firefox' own sidebar isn't tinted here. Safari is the only one that sets the same exact "Canvas" color as some preference panes, but it's easy because Safari doesn't support tinting. https://codepen.io/fregante/pen/oNrMJWB?editors=1100 |
Could you provide scenario's that you'd like to cover with the request for querying the current theme? System colors should be used where applicable. For other cases, the group's general preference is to expose this through CSS variables, instead of an API such as
Originally the motivation was "Well, the default theme(s) does more than what the theming api can do, which makes it hard to return theme data." per https://bugzilla.mozilla.org/show_bug.cgi?id=1435216#c4. |
Indeed, some theme values can't be exposed due to their dynamic nature. However, exposing a well-defined set of CSS variables would be a good start and would greatly benefit extensions that want to match the browser theme or system appearance. One of the dynamic complexities on Apple platforms is that the background material is often a blurred "glass" effect, tinted based on the background content. Since this isn’t a single color, we can support it by rendering extension web views with a transparent background, allowing HTML content to composite over it. Although we already do this for popups in Safari, most extensions don’t take advantage of it because they set a solid color for the background of the body or main element. If we exposed a background color variable, it would likely return Safari extensions can access system colors today via WebKit’s |
Problem Statement
Users can change the browser’s default theme. Extensions have no way to get the browser’s current theme information and style their UI accordingly. The below screenshots demonstrate the problem.
Extension popup cannot be styled as per the browser theme.
Other browser dialogs are styled appropriately.
Chromium bugs / developer requests:
Current Support
Firefox
Similarly, there is a browser.theme.onUpdated event which is fired when an extension supplied theme is changed.
Chromium
chrome.theme
namespace.Questions
Proposal
Like Firefox, other browsers (Chromium and Safari) should implement
theme.getCurrent()
API to enable extensions to retrieve browser’s theme information.Opening this issue to get feedback from the community group. We will work on a formal proposal after we have consensus on the next steps.
The text was updated successfully, but these errors were encountered: