You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Problem Description
Browsers currently support a way to trigger a dark mode rendering by setting a color-scheme meta tag, or defining a color-scheme css property on the :root element. When this is set to dark, browsers will automatically render a dark background behind the webcontents, as well as change the text color.
Regular browser windows in Electron will switch this background color along with the text color, but other webcontents, like those in webviews don't. This results in rendering white text on a white ( transparent) background when color-scheme is set to dark.
You could use JS to read out the color-scheme meta tag and find if color-scheme is a defined CSS property and manually set a background color behind a webview. This will work once but the color-scheme value can update at any moment with no additional signal, which can make webviews unreadable.
Note this is a distinct feature from prefers-color-scheme. That indicates the preference of the user, while color-scheme indicates whether a site supports dark, light or both.
Proposed Solution
An event on webContents that is called when the color-scheme changes, similar to the did-change-theme-color event we already have.
Alternatives Considered
Injected JavaScript listeners that observe the CSSStyleSheet and DOM tree.
Chrome itself forces a dark background on iframes (see example 3 below). We could do the same for webviews.
Codepen of the above demo page set in an iframe: https://codepen.io/Kilian/pen/xxpNvEb Notice that in Chromium the background of the iframe does update.
The text was updated successfully, but these errors were encountered:
Preflight Checklist
Problem Description
Browsers currently support a way to trigger a dark mode rendering by setting a
color-scheme
meta tag, or defining acolor-scheme
css property on the:root
element. When this is set todark
, browsers will automatically render a dark background behind the webcontents, as well as change the text color.To see this in action, see this demo page: https://color-scheme-demo.glitch.me/ (warning: This will flip from light to dark every three seconds) and accompanying explainer article: https://web.dev/color-scheme/
Regular browser windows in Electron will switch this background color along with the text color, but other webcontents, like those in
webviews
don't. This results in rendering white text on a white ( transparent) background when color-scheme is set to dark.You could use JS to read out the
color-scheme
meta tag and find ifcolor-scheme
is a defined CSS property and manually set a background color behind a webview. This will work once but the color-scheme value can update at any moment with no additional signal, which can make webviews unreadable.Note this is a distinct feature from
prefers-color-scheme
. That indicates the preference of the user, whilecolor-scheme
indicates whether a site supports dark, light or both.Proposed Solution
An event on webContents that is called when the color-scheme changes, similar to the
did-change-theme-color
event we already have.Alternatives Considered
Additional Information
The text was updated successfully, but these errors were encountered: