https://github.com/juliuste/closest-css-color
Find the closest CSS color keyword for a given HEX color value.
https://github.com/juliuste/closest-css-color
library
Last synced: about 1 year ago
JSON representation
Find the closest CSS color keyword for a given HEX color value.
- Host: GitHub
- URL: https://github.com/juliuste/closest-css-color
- Owner: juliuste
- License: isc
- Created: 2018-03-08T05:48:18.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2021-05-31T04:01:06.000Z (about 5 years ago)
- Last Synced: 2024-10-17T05:29:18.473Z (over 1 year ago)
- Topics: library
- Language: JavaScript
- Size: 6.84 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# closest-css-color
Find the closest CSS color keyword for a given hex color value.
[](https://www.npmjs.com/package/closest-css-color)
[](https://travis-ci.org/juliuste/closest-css-color)
[](license)
[](mailto:mail@juliustens.eu)
## Installation
```bash
npm install --save closest-css-color
```
## `closestColor(hex, { detailed = false }})`
```js
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](https://github.com/juliuste/closest-css-color/issues).