-
Notifications
You must be signed in to change notification settings - Fork 55
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
Displaying webpage in dark mode #5102
Comments
Hi @ajtruckle, Just to clarify, are you looking for a feature that includes a toggle button for wv2 users to switch between Light and Dark Mode? Also, are you inquiring whether this feature is currently live? Thank you! |
Hi @sivMSFT
|
Hi @ajtruckle, you can use the CoreWebView2Profile.PreferredColorScheme property to set the dark mode. This property allows you to choose between dark mode, light mode, or the OS default, and it should apply to all the WebView2 owned UI. You can also enable Auto Dark Mode through AdditionalBrowserArguments: |
@sivMSFT But, as for the other aspect of this, it looks like I need to use media queries. For example: /* Dark mode for screens only */
@media screen and (prefers-color-scheme: dark) {
body {
background-color: black;
color: white;
}
} I have tested in Edge so assume that WebView2 will also work. |
I notice in Microsoft Edge it has a toggle to attempt to display the loaded page in dark mode.
I appreciate that nothing can be better than a dedicated dark colour scheme using CSS, but is it possible to toggle this same setting for a page using WebView2?
The text was updated successfully, but these errors were encountered: