Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-22 20:24:04 +03:00
parent aedcded750
commit d35575373f
41 changed files with 148 additions and 88 deletions

View File

@ -3,13 +3,15 @@ title: prefersDarkColorScheme
tags: browser,intermediate
---
Returns `true` if the user color scheme preference is `dark`, `false` otherwise.
Checks if the user color scheme preference is `dark`.
- Use `Window.matchMedia()` with the appropriate media query to check the user color scheme preference.
```js
const prefersDarkColorScheme = () =>
window && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
window &&
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
```
```js