closest-css-color

Find the closest CSS color keyword for a given HEX color value.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
closest-css-color
301.0.0a year ago4 years agoMinified + gzip package size for closest-css-color in KB

Readme

closest-css-color
Find the closest CSS color keyword for a given hex color value.
npm version Build status License Contact me

Installation

npm install --save closest-css-color

closestColor(hex, { detailed = false }})

const closestColor = require('closest-css-color')

// normal usage
const color = closestColor('#a00a0a')
console.log(simpleColor)
// -> 'darkred'

// with the `detailed` option
const colorWithAdditionalInformation = closestColor('#1019a6', { detailed: true })
console.log(detailedColor)
// -> {
//     name: 'darkblue',
//     hex: '#00008b',
//     rgb: {red: 0, green: 0, blue: 139}
// }

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.