Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

detect browser theme

if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
  console.log('User prefers dark mode on his device');
}
 
PREVIOUS NEXT
Tagged: #detect #browser #theme
ADD COMMENT
Topic
Name
7+2 =