Skip to content

ts-web/css-color-names-rgb

Repository files navigation

npm version Downloads Uses TypeScript

css-color-names-rgb

These are the CSS color names from the CSS spec, as numeric RGB values.

Does not include transparent or currentcolor.

All color names are lowercase. If needed, transform colors using myColor.toLowerCase() before passing.

This library is optimized for parsing using JSON.parse (See https://v8.dev/blog/cost-of-javascript-2019#json).

Example

import { cssColors } from 'css-color-names-rgb';

console.log(cssColors.papayawhip);
// [255, 239, 213]

Utilities

import {
  type ColorName,
  isCssColorName,
  getColor,
} from 'css-color-names-rgb';

Comparison with other libraries

  • color-name doesn't have types included (DT only), and doesn't use JSON.parse to optimize load time.
  • css-color-names doesn't have RGB values.
  • html-colors doesn't have RGB values.
  • css-spec-colors returns RGB values in the form of a CSS rgb() string.
  • named-css-colors calculates RGB values from hex, freezes objects, and includes extra utils.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published