Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

detect system dark mode javascrip

 const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
  if (darkTheme.matches) {
       document.documentElement.classList.add("dark");
    } else {
      document.documentElement.classList.remove("dark");
       }
Source by 1loc.dev #
 
PREVIOUS NEXT
Tagged: #detect #system #dark #mode #javascrip
ADD COMMENT
Topic
Name
1+5 =