Why `window.matchMedia('(prefers-color-scheme: dark)').matches` returns `false` in Ubuntu Dark Mode
Asked Answered
N

2

7

I'm using Ubuntu and trying to get the preferred theme of the user, by using matchMedia but it always returns false for this query.

window.matchMedia('(prefers-color-scheme: dark)').matches // false
Nanettenani answered 18/4, 2022 at 6:51 Comment(0)
S
4

This is an open issue in Chrome.

Sypher answered 18/4, 2022 at 7:2 Comment(0)
M
2

This is a problem between Ubuntu and Chrome. Please check darkmood toggle with Ubuntu and Firefox. Then you can see it’s working without any issue.

So that's why I think it's a problem between Ubuntu and Chrome.

This is a known issue that is traceable through this page.

Marriageable answered 18/4, 2022 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.