Watch OS Color Scheme
Watch OS Color Scheme lets you watch your OS color scheme, similar to the
Media Queries @media (prefers-color-scheme)
specification.
Usage
Add Watch OS Color Scheme to your project:
npm install watch-os-color-scheme
Watch the OS for color scheme changes:
const watchOsColorScheme = ; const stop = ; ;
Watch OS Color Scheme takes 2 arguments; a callback
and an interval
; and
it returns a stop
function.
callback
The callback
listener is called as the color scheme is initially detected and
then each time the color scheme subsequently changes. It returns a single
argument; a colorScheme
string representing the preferred color scheme of the
OS, which is either no-preference
, light
, or dark
.
interval
The interval
number indicates how often the color scheme should be polled in
milliseconds.
stop
The stop
function stops watching for color scheme changes.