# watch-os-color-scheme

> Watch the OS color scheme

Latest version **1.0.2** (published 2018-10-14) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install watch-os-color-scheme
pnpm add watch-os-color-scheme
yarn add watch-os-color-scheme
bun add watch-os-color-scheme
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-10-14 |
| First published | 2018-10-14 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jonathan Neal |
| Maintainers | jonathantneal |
| Keywords | watch, os, prefers, color, scheme |

## Links

- npm: https://www.npmjs.com/package/watch-os-color-scheme
- Repository: https://github.com/jonathantneal/watch-os-color-scheme
- Homepage: https://github.com/jonathantneal/watch-os-color-scheme#readme
- Issues: https://github.com/jonathantneal/watch-os-color-scheme/issues
- npm.io page: https://npm.io/package/watch-os-color-scheme

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-10-14
- 1.0.1 — 2018-10-14
- 1.0.0 — 2018-10-14

## README

# Watch OS Color Scheme [<img src="https://jonathantneal.github.io/node-logo.svg" alt="stylelint" width="90" height="90" align="right">][Watch OS Color Scheme]

[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]

[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:

```bash
npm install watch-os-color-scheme
```

Watch the OS for color scheme changes:

```js
const watchOsColorScheme = require('watch-os-color-scheme');

const stop = watchOsColorScheme(prefersColorScheme => {
  console.log({ prefersColorScheme }); // no-preference | light | dark
});

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.

[cli-img]: https://img.shields.io/travis/jonathantneal/watch-os-color-scheme.svg
[cli-url]: https://travis-ci.org/jonathantneal/watch-os-color-scheme
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/stylelint/stylelint
[npm-img]: https://img.shields.io/npm/v/watch-os-color-scheme.svg
[npm-url]: https://www.npmjs.com/package/watch-os-color-scheme

[Media Queries]: https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-scheme
[Watch OS Color Scheme]: https://github.com/jonathantneal/watch-os-color-scheme

---
_Source: https://npm.io/package/watch-os-color-scheme · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
