What is css-color-keywords?
The css-color-keywords package provides a list of CSS color keywords as specified in CSS Color Module Level 4. It allows developers to access a comprehensive list of predefined color names that can be used in CSS files, making it easier to apply color styles without needing to remember specific color codes.
What are css-color-keywords's main functionalities?
Accessing CSS Color Keywords
This feature allows you to access the hexadecimal color code for CSS color keywords. The example demonstrates how to retrieve the color code for 'red'.
const colors = require('css-color-keywords');
console.log(colors.red); // Outputs the color code for 'red'
Iterating Over All Color Keywords
This feature enables iterating over all available CSS color keywords and their corresponding color codes. The code sample iterates through the color keywords and prints each color name along with its hexadecimal code.
const colors = require('css-color-keywords');
for (const color in colors) {
console.log(`${color}: ${colors[color]}`);
}
Other packages similar to css-color-keywords
color-name
The color-name package offers a list of color names and their RGB values. It is similar to css-color-keywords but provides RGB values instead of hexadecimal codes, making it more suitable for applications that require RGB format.
colornames
colornames provides a mapping between color names and their hexadecimal codes, similar to css-color-keywords. However, it also includes additional functionality for converting color names to RGB values and vice versa, offering more versatility.
css-color-keywords
A list of all CSS color keywords.
This list contains all CSS color keywords specified in:
See MDN for an overview of all colors.
Installation
$ npm install css-color-keywords --save
Usage
const cssColorKeywords = require('css-color-keywords')
cssColorKeywords.black
cssColorKeywords.orange
Returns an object where each key is a keyword (e.g. black
) and the value is
the keyword’s RGB hex value (e.g. #000000
).
Even though CSS color keywords are case-insensitive, this list only contains
lowercase keywords (and returns lowercase RGB hex values).
Changelog
This project follows Semantic Versioning 2.
This list aims to always include all CSS color keywords. If new keywords are
specified, only the minor version will be bumped.
- v1.0.0 (2017-01-20): Initial release
License
css-color-keywords
is licensed under the ISC license.
See LICENSE
for the full license.