shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
isDarkMode
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.is
Detect if the user prefer the dark mode. Dark mode is detected using:
- Match the media query
prefers-color-scheme: dark - Check if an element has the class
-darkon it or any of its parents (up to the document root)
Return
- -Boolean
true if prefer dark mode, false if not
Example
import { isDarkMode } from '@blackbyte/sugar/is'
if (isDarkMode()) {
// do something cool
}Settings
- ctxwindowWindow
The window context to use
- [rootNode]*-HTMLElement
An optional root node to check for the
-darkclass
Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space