A JSON with all CSS color keywords and their corresponding values in hex, RGB and HSL.
The color list is generating by scrapping the W3C spec (https://www.w3.org/TR/css-color-4/#named-colors).
Using npm:
$ npm install css-spec-colors
Or yarn:
$ yarn add css-spec-colors
You can also download the JSON file directly from unpkg or Netlify without installing any dependency.
Colors are sorted alphabetically
import colors from 'css-spec-colors'; // or const colors = require('css-spec-colors');
// All colors
console.log(colors);
/*
{
aliceblue: {
name: 'aliceblue',
hex: '#f0f8ff',
rgb: 'rgb(240, 248, 255)',
hsl: 'hsl(208, 100%, 97.1%)'
},
antiquewhite: {
name: 'antiquewhite',
hex: '#faebd7',
rgb: 'rgb(250, 235, 215)',
hsl: 'hsl(34, 77.8%, 91.2%)'
}
...
}
*/
// Get a color by name
console.log(colors.aliceblue);
/*
{
name: 'aliceblue',
hex: '#f0f8ff',
rgb: 'rgb(240, 248, 255)',
hsl: 'hsl(208, 100%, 97.1%)'
}
*/
// Get the hex value of a color
console.log(colors.aliceblue.hex); // '#ff0000'
// Get the RGB value of a color
console.log(colors.aliceblue.rgb); // 'rgb(255, 0, 0)'
// Get the HSL value of a color
console.log(colors.aliceblue.hsl); // 'hsl(0, 100%, 50%)'
MIT
Made with