Menu

gitpiper

prefersDarkColorScheme javascript Code Snippet in 2024

browserintermediate

Last Updated: 3 November 2024

Checks if the user color scheme preference is dark.

  • Use 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

javascript snippet similar to prefersDarkColorScheme For You in November 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️