# is-dark-color-hsp

> Package to detect if a color is dark or not

Latest version **2.1.0** (published 2026-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-dark-color-hsp
pnpm add is-dark-color-hsp
yarn add is-dark-color-hsp
bun add is-dark-color-hsp
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2026-04-07 |
| First published | 2021-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Aarón Montes |
| Maintainers | ajomuch92 |
| Keywords | color, dark, ligh, determine, javascript |

## Links

- npm: https://www.npmjs.com/package/is-dark-color-hsp
- Repository: https://github.com/ajomuch92/is-dark-color-hsp
- Homepage: https://github.com/ajomuch92/is-dark-color-hsp#readme
- Issues: https://github.com/ajomuch92/is-dark-color-hsp/issues
- npm.io page: https://npm.io/package/is-dark-color-hsp

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2026-04-07
- 2.0.1 — 2025-02-01
- 2.0.0 — 2025-01-31
- 1.2.0 — 2023-02-02
- 1.0.1 — 2021-09-19
- 1.0.0 — 2021-09-19

## README

# Is Dark Color HSP

This package helps to determine if a color is dark tone or light tone. It's useful to use a contrast color (as you can see on demo image using on an app) with other. It's based on HSP(Highly Sensitive Poo) color model, you can read more about it [here](http://alienryderflex.com/hsp.html).

See an example [here](https://github.com/ajomuch92/is-dark-color-hsp/blob/master/example/index.js)

<img src="https://raw.githubusercontent.com/ajomuch92/flutter-is-dark-color-hsp/master/assets/demo.gif" width="200" height="429"/>

## Installation

`npm install --save is-dark-color-hsp`

## Usage

```javascript
import isDarkColorHsp from "is-dark-color-hsp"; // you can import them individually as `import { isDark, isLight } from 'is-dark-color-hsp'`

const whiteIsDark = isDarkColorHsp.isDark("#ffffff"); // false
const blackIsDark = isDarkColorHsp.isDark("rgb(0, 0, 0)"); // true
const otherColor = isDarkColorHsp.isLight("#ff9900"); // true
const otherColor = isDarkColorHsp.isDark("hsl(142, 42%, 42%)"); // true
const nonColor = isDarkColorHsp.isDark({}); // null
```

## Breaking changes 💥

The package is now built using TypeScript, while the core functionality remains unchanged. If you encounter any issues or have suggestions, please feel free to open an issue.

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