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

Viewed 640

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
2 Answers

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.

Related