Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript detect dark mode

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Comment

detect dark mode javascript

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    console.log(` is dark`);
}else{
  console.log(`shiit is light`);
}
Comment

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");
       }
Comment

javascript detect dark mode

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches

console.log(isDarkMode) // Result: True or False
Comment

js if dark mode

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    // dark mode
}
Comment

dark mode javascript

// Enter code directly in the console for instant dark mode.
var allDivs = document.querySelectorAll('div');

for(var i = 0; i < allDivs.length; i++){
  allDivs[i].style['background-color'] = 'black';
  allDivs[i].style['color'] = 'green';
  allDivs[i].style['font-family'] = 'Monospace';
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: vue property decorator emit 
Javascript :: react-select dropdown open inside modal 
Javascript :: async storage has been extracted from react-native core 
Javascript :: get element with one or another class 
Javascript :: javascript transpose rows to columns 
Javascript :: javascript string lentrh 
Javascript :: javascript hide address bar mobile 
Javascript :: get cookie value in javascript 
Javascript :: detect system dark mode javascrip 
Javascript :: javascript range 
Javascript :: regex on input 
Javascript :: set css variable from javascript 
Javascript :: get express variable 
Javascript :: redirect with react router v6 
Javascript :: change href with jquery 
Javascript :: javascript document remove 
Javascript :: adding new sass version 
Javascript :: register a service worker 
Javascript :: how to detect if ios is in dark mode react native 
Javascript :: jquery confirm dialog 
Javascript :: repeat string n times javascript 
Javascript :: check if localstorage key exists js 
Javascript :: jest testmatch specific folder 
Javascript :: react native disable the text input 
Javascript :: usenavigate react router dom v6 
Javascript :: js get date in ms 
Javascript :: refresh page on div click 
Javascript :: how to delete element at a particular index of array in react js 
Javascript :: javascript for loop on object 
Javascript :: javascript detect backspace 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =