Skip to content
🎨 Modern JavaScript color utilities library
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
scripts
src
test
.babelrc
.eslintrc.json
.gitignore
.prettierrc.js
.travis.yml
LICENSE
README.md
commitlint.config.js
jest.config.js
logo.svg
package.json
rollup.config.ts
tsconfig.json
yarn.lock

README.md

Build Status codecov Codacy Badge


Modern and Modular JavaScript color utility library. inspired by date-fns.

Features

  • Written in TypeScript. 😎
  • Lightweight. πŸ’Έ
  • Modular and Tree-shakable.🌳
  • Multi-Color Model Support. 🎨
  • CSS compatible output. πŸ’¨

Installation

# yarn
yarn add color-fns

# npm
npm i color-fns

OR

<script src="https://unpkg.com/color-fns"></script>

Usage

// ES2015 (ES6)
import { toRgb } from 'color-fns';

console.log(toRgb('#fff'));


// CommonJS
const { toRgb } = require('color-fns');
console.log(toRgb('#fff'));

// UMD (Script Tag)
console.log(ColorFns.toRgb('#fff'));

Available Functions

Parsing

  • parseCmyk
  • parseHex
  • parseHsl
  • parseHsv
  • parseRgb

Conversion

  • cmykToRgb
  • hexToRgb
  • hslToRgb
  • hsvToRgb
  • rgbToCmyk
  • rgbToHex
  • rgbToHsl
  • rgbToHsv
  • toCmyk
  • toHex
  • toHsl
  • toHsv
  • toRgb

Operations

  • mix

Format and Display

  • expandHexShorthand
  • formatCmyk
  • formatHex
  • formatHsl
  • formatHsv
  • formatRgb

Validation

  • isValidCmyk
  • isValidHex
  • isValidHsl
  • isValidHsv
  • isValidRgb

Querying

  • whichModel
  • constrastInfo
  • isDark
  • hexFromName
  • hexToName

Calculations

  • relativeLuminance

Contribution

Contributions are welcomed, however make sure you read the contribution guide and the code of conduct before making any pull requests.

License

MIT

You can’t perform that action at this time.