# the-simplest-color-checker

> A powerful, dependency-free color manipulation library

Latest version **4.1.3** (published 2025-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install the-simplest-color-checker
pnpm add the-simplest-color-checker
yarn add the-simplest-color-checker
bun add the-simplest-color-checker
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.3 |
| Published | 2025-01-21 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0 |
| Dependencies | 0 |
| Unpacked size | 38.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Ahmed Ouda |
| Maintainers | amans199 |
| Keywords | color, utilities, palette, contrast, accessibility |

## Links

- npm: https://www.npmjs.com/package/the-simplest-color-checker
- Repository: https://github.com/amans199/the-simplest-color-checker
- Homepage: https://github.com/amans199/the-simplest-color-checker#readme
- Issues: https://github.com/amans199/the-simplest-color-checker/issues
- npm.io page: https://npm.io/package/the-simplest-color-checker

## 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

- 4.1.3 (latest) — 2025-01-21
- 4.1.2 — 2025-01-21
- 4.0.2 — 2025-01-16
- 4.0.1 — 2025-01-16
- 4.0.0 — 2025-01-16
- 3.0.0 — 2025-01-02
- 2.1.3 — 2020-11-19
- 2.0.3 — 2020-11-19
- 2.0.1 — 2020-11-19
- 1.0.0 — 2020-07-20

## README

# The Simplest Color Checker Library

A powerful, dependency-free color manipulation library for JavaScript/TypeScript applications.


<div style="text-align:center;">
  <h3 >Manipulate colors easily</h3>
  <h4 >This (text has a very low contrast) : </h4>
    <br />
    <img  src="./assets/images/dynamic_backgrounds_before_using_color_checker.PNG" alt="dynamic_backgrounds_before_using_color_checker" width="500" >
    <br />
    <h4 >Can be turned easily into this: (High contrast with the background)  </h4>
    <img   src="./assets/images/dynamic_backgrounds_after_using_color_checker.PNG" alt="dynamic_backgrounds_after_using_color_checker" width="500" >
    <br />
</div>


## Features

- Color validation (HEX, RGB, HSL)
- Brightness calculation
- Contrast ratio calculation
- Color format conversions
- Color palette generation
- CSS integration utilities
- WCAG accessibility checks

## Installation

```bash
npm install the-simplest-color-checker
```

## Full API
Go to https://github.com/amans199/the-simplest-color-checker/blob/master/API.md


## Basic Usage

```typescript
import { isLight, getContrastRatio } from 'the-simplest-color-checker';

// Check if a color is light or dark
const color = '#3498db';
console.log(isLight(color)); // false

// Calculate contrast ratio
const ratio = getContrastRatio('#000000', '#ffffff');
console.log(ratio); // 21 (maximum contrast)
```

## API Documentation

### Validation

```typescript
isValidHex(color: string): boolean
isValidRGB(r: number, g: number, b: number): boolean
isValidHSL(h: number, s: number, l: number): boolean
```

### Color Conversions

```typescript
hexToRGB(hex: string): { r: number; g: number; b: number }
rgbToHex(r: number, g: number, b: number): string
rgbToHSL(r: number, g: number, b: number): { h: number; s: number; l: number }
```

### Brightness

```typescript
getBrightness(color: string): number
isLight(color: string): boolean
```

### Contrast

```typescript
getContrastRatio(color1: string, color2: string): number
```

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the LICENSE file for details.

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