-
Notifications
You must be signed in to change notification settings - Fork 51
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
WebView2 isn't respecting the Profile.PreferredColorScheme for the scrollbars #3696
Comments
Thanks for reporting the issue and sorry you are running into it. I've assigned this to a dev who can help follow up on this. |
@zhuman I am seeing the theme color respected. Is there a website that is or isn't working for you or is it any website that normally honors theme color? |
This is how it looks by default in WinUI3 (using the latest version). However I did find that simply setting it in js works fine, i.e.: I provided the screenshot as to demonstrate how WinUI3 is in dark mode (correctly) while WebView2 scrollbar isn't by default. Devtools, menus and the such are working correctly. I don't know if them being light or dark by default is even a bug (I guess it's hard to really tell whether the website itself respects the theme) but setting it in c# doesn't work for me, like OP described. |
@bojan-sala-igt-com - thank you for the screenshot! I'm thinking this is a website issue. What website are you using in the screenshot? When I'm on youtube or github.com/features/codespaces, websites I know to respect OS theme, the scrollbar is dark with no other code. |
It was indeed a website issue, which I found out later and edited the comment but wasn't 100% sure if that's intended behavior 🙂 Doing something along the lines of: if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
} Fixed it for me. |
Adding |
Hi all folks in the thread. Yes, you need to make sure your page's |
Description
Setting the CoreWebView2.Profile.PreferredColorScheme to Dark doesn't affect the scrollbars in a WinUI3 app using WinAppSDK.
Version
SDK: Packaged in the WinAppSDK
WinAppSDK: 1.3.230724000
Runtime: Stable channel Edge I assume
Framework: WinUI3 using WinAppSDK
OS: Win11 Dev Channel build 23521
Regression
Was this working before but has regressed? no, this is the first version of the WinAppSDK that has the PreferredColorScheme available I think
If yes, what version did this last work on? N/A
Repro Steps
Screenshots
Additional context
The text was updated successfully, but these errors were encountered: