-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[bug] Tauri window theme is not propagated to webview (prefers-color-scheme
)
#5802
Comments
I did some research and found the root cause. Tauri uses wry to handle WebView stuff, and wry calls APIs exposed by webview2-com. The original interface of the WebView core, I did a local test, by adding the following line to wry
and now my Tauri app will unconditionally use Light color scheme regardless of my Windows color settings. It seems Tauri currently only sets |
/upstream tauri-apps/wry |
Upstream issue at tauri-apps/wry#806 has been closed. |
@CrendKing thanks for the research, this has been implemented in upstream and when that is released, we will call it internally when changing the window theme. |
Thanks. That's very fast patch. Looking forward to the fix here. |
…ps#5802 (tauri-apps#5874) Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Describe the bug
No matter which theme I set in the Tauri config file, the WebView always answers CSS media query
prefers-color-scheme
with OS color theme. According to the doc, it should only be the behavior is thetheme
field isNone
.There is a similar issue in Electron, and they managed to fix it by "propagate preferred color scheme to the renderer".
Reproduction
windows[0].theme
to "Light".main()
, call main window'stheme()
to make sure it istauri::Theme::Light
.@media (prefers-color-scheme: light)
and@media (prefers-color-scheme: dark)
.@media (prefers-color-scheme: dark)
is used.Expected behavior
If
theme()
returnsLight
, styles in@media (prefers-color-scheme: light)
should be used.Platform and versions
Stack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: