Skip to content

Installation

Requirements

Requires Node.js 18+. No runtime or peer dependencies — the package is fully framework-agnostic and works in any JS/TS environment (browser, Node, edge runtimes).

Installation

bash
npm install color-value-tools

Quick start

ts
import {
  normalizeColor,
  mixColors,
  lighten,
  darken,
  saturate,
  complement,
  triadic,
  wcagLevel,
  bestTextColor,
  colorDeltaE,
  randomColor,
} from 'color-value-tools'

// Parse any color format
normalizeColor('#3498db')
// { type: 'hex', hex: '#3498db', r: 52, g: 152, b: 219, a: 1, h: 204, s: 70, l: 53, v: 86 }

// Manipulate
lighten('#3498db', 15) // '#74b9e7'
darken('#3498db', 15) // '#1d6ea5'
saturate('#3498db', 20) // '#1b9df3'

// Harmonies
complement('#3498db') // '#db7633'
triadic('#3498db') // ['#3498db', '#db3398', '#98db33']

// WCAG accessibility
wcagLevel('#ffffff', '#3498db') // 'AA-large'
bestTextColor('#3498db') // '#000000'

// Perceptual color distance (CIEDE2000)
colorDeltaE('#ff0000', '#fe0000') // 0.2079

// Random color within a hue/saturation range
randomColor({ hRange: [200, 260], sRange: [60, 80] })

CommonJS:

js
const { normalizeColor, mixColors } = require('color-value-tools')