Skip to content
Detect dark mode in a browser
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
_config.yml
darkdetector.js
package.json
yarn.lock

README.md

Travis CI Build Status CodeFactor Score

Dark Detector

NPM

Detect dark mode in any browser.

Importing

From your NodeJS application:

const DarkDetector = require("darkdetector")

From your web application:

<script src="https://unpkg.com/darkdetector/darkdetector.min.js"></script>

Usage

// Check if dark mode enabled
if (DarkDetector({
    query: true, // Check for dark mode media query
    highcontrast: false, // Check for white on black media query
    bodyclass: false, // Check for class on body class
    time: false // Check for night time
})) console.log("Dark mode is enabled.")
You can’t perform that action at this time.