Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

css-color-names-rgb

ts-web15MIT1.0.4TypeScript support: included

CSS color names in RGB format, from the spec.

css, colors, rgb, names, named, color names, spec

readme

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.

changelog

1.0.4

  • No changes. First GH Actions publish.

1.0.3

  • Edit readme (no functional changes).

1.0.2

  • Fix the package.json module field to point to the ESM version (index.mjs)

1.0.1

  • Remove src from the published package.

1.0.0

  • Initial version.