https://github.com/timoxley/colornames
Map color names to HEX color values
https://github.com/timoxley/colornames
Last synced: 9 months ago
JSON representation
Map color names to HEX color values
- Host: GitHub
- URL: https://github.com/timoxley/colornames
- Owner: timoxley
- License: mit
- Created: 2012-11-20T21:31:59.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2021-06-20T04:30:34.000Z (over 4 years ago)
- Last Synced: 2025-03-30T09:09:32.697Z (10 months ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 50
- Watchers: 4
- Forks: 21
- Open Issues: 6
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome_frontend_development_resources - colornames - Map color names to HEX color values. (Color / React Components)
- awesome - colornames - Map color names to HEX color values. (Color / React Components)
README
# colornames
### Convert color names to HEX color values.
[](https://nodei.co/npm-dl/colornames/)
[](https://nodei.co/npm/colornames/)
[](https://travis-ci.org/timoxley/colornames)
[](https://david-dm.org/timoxley/colornames)
## Installation
### Component
$ component install timoxley/colornames
### Node/Browserify
$ npm install colornames
## Example
```js
var toHex = require('colornames')
```
### VGA color names
```js
toHex('red') // => "#FF0000"
toHex('blue') // => "#0000FF"
```
### CSS color names
```js
toHex('lightsalmon') // => "#FFA07A"
toHex('mediumvioletred') // => "#C71585"
```
### Get meta data about a color
```js
toHex.get('red')
// =>
{
name: "red",
css: true,
value: "#FF0000",
vga: true
}
```
### Conversion is case-insensitive
```js
toHex('Blue') // => "#0000FF"
toHex('BLUE') // => "#0000FF"
toHex('BlUe') // => "#0000FF"
```
## API
### colornames(name)
Get HEX code for a color name, or `undefined` if unknown.
### .get(name)
All known data about color, including whether valid VGA or CSS color
name.
### .get.vga(name)
HEX code for a color name, only if the color is a valid VGA color
name.
### .get.css(name)
HEX code for a color name, only if the color is a valid CSS color
name.
###.all()
Get all color names data.
## License
MIT
## Complete Color Map
