Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get os theme value in javascript

    function osTheme(){
        let primarytheme = "";
        if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
            primarytheme = "dark";
        }
        else{
            primarytheme = "light"
        }
        return primarytheme;
    }
 
PREVIOUS NEXT
Tagged: #os #theme #javascript
ADD COMMENT
Topic
Name
4+2 =