
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 add color-fns
npm i color-fns
OR
<script src="https://unpkg.com/color-fns"></script>
Usage
import { toRgb } from 'color-fns';
console.log(toRgb('#fff'));
const { toRgb } = require('color-fns');
console.log(toRgb('#fff'));
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
Format and Display
- expandHexShorthand
- formatCmyk
- formatHex
- formatHsl
- formatHsv
- formatRgb
Validation
- isValidCmyk
- isValidHex
- isValidHsl
- isValidHsv
- isValidRgb
Querying
- whichModel
- constrastInfo
- isDark
Calculations
Contribution
Contributions are welcomed, however make sure you read the contribution guide and the code of conduct before making any pull requests.
License
MIT