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

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

PREVIOUS NEXT
Code Example
Javascript :: how to create a folder using fs in node js 
Javascript :: countdown in js 
Javascript :: react native getstream 
Javascript :: save image jpg javascript 
Javascript :: finddomnode is deprecated in strictmode 
Javascript :: run onclick function once javascript 
Javascript :: install vue by CDN 
Javascript :: Capitalize the first letter of string using JavaScript 
Javascript :: js array last element get 
Javascript :: tonumber javascript 
Javascript :: format date javascript 
Javascript :: create react app with vite 
Javascript :: select elements of an array starting by a certain letter javascript 
Javascript :: js largura da tela 
Javascript :: hide a div in jquery 
Javascript :: floating button react 
Javascript :: Use Multiple Conditional Ternary Operators Javascript 
Javascript :: js convert string array to number array 
Javascript :: install stripe to react/nodejs - typescript 
Javascript :: javascript date to string format dd mmm yyyy 
Javascript :: use style in react 
Javascript :: inline styling in react 
Javascript :: how to make dynamic title for screen in react native 
Javascript :: how to check if an element exists in an array of objects js 
Javascript :: repeat array in js 
Javascript :: jsonwebtoken error with react js 
Javascript :: recursion in javascript 
Javascript :: exporting a class 
Javascript :: BREAK A LINE on JS 
Javascript :: puppeteer set download path 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =