User prefers dark color scheme
Checks if the user color scheme preference is
Window.matchMedia()with the appropriate media query to check the user color scheme preference.
const prefersDarkColorScheme = () => window && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
prefersDarkColorScheme(); // true
Written by Angelos Chalaris
If you want to keep in touch, follow me on GitHub or Twitter.