{"id":12952,"library":"chartjs-color-string","title":"CSS Color String Parser and Generator for Chart.js","description":"This library, `chartjs-color-string`, provides utilities for parsing and generating CSS color strings in various formats, including named colors, hex, rgb(a), and hsl(a). It outputs color components as numerical arrays. While it is part of the Chart.js ecosystem, its latest version, 0.6.0, was published over seven years ago, indicating a mature and stable, but infrequently updated, project. It supports modern CSS color string formats like `#rgba` and `#rrggbbaa` since version 0.6.0 and case-insensitive parsing of RGB(A) strings since 0.5.0. Its primary differentiator is its lightweight focus on string conversion, making it suitable for environments where a full-featured color manipulation library is not needed. The package should be considered in maintenance mode.","status":"maintenance","version":"0.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/chartjs/chartjs-color-string","tags":["javascript","color","colour","rgb","css"],"install":[{"cmd":"npm install chartjs-color-string","lang":"bash","label":"npm"},{"cmd":"yarn add chartjs-color-string","lang":"bash","label":"yarn"},{"cmd":"pnpm add chartjs-color-string","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library exports its functions as properties of a single object, typically imported as a namespace.","wrong":"import colorString from 'chartjs-color-string';","symbol":"colorString","correct":"import * as colorString from 'chartjs-color-string';"},{"note":"CommonJS require is the historically common way to import this library.","symbol":"colorString","correct":"const colorString = require('chartjs-color-string');"},{"note":"Individual functions like `getRgb` are not direct named exports; they are accessed via the main `colorString` import, e.g., `colorString.getRgb`.","wrong":"import { getRgb } from 'chartjs-color-string';","symbol":"getRgb","correct":"import { getRgb } from 'chartjs-color-string'; /* NOT a direct export */"}],"quickstart":{"code":"import * as colorString from 'chartjs-color-string';\n\n// Parsing examples\nconst blueRgb = colorString.getRgb('blue');\nconsole.log('Blue (RGB):', blueRgb); // Expected: [0, 0, 255]\n\nconst hexWithAlpha = colorString.getRgba('#FFFA');\nconsole.log('Hex with Alpha (RGBA):', hexWithAlpha); // Expected: [255, 255, 255, 0.67]\n\nconst rgbaString = colorString.getRgba('rgba(200, 60, 60, 0.3)');\nconsole.log('RGBA String (RGBA):', rgbaString); // Expected: [200, 60, 60, 0.3]\n\n// Generation examples\nconst whiteHex = colorString.hexString([255, 255, 255]);\nconsole.log('White Hex:', whiteHex); // Expected: \"#FFFFFF\"\n\nconst blueRgbaString = colorString.rgbString([0, 0, 255, 0.4]);\nconsole.log('Blue RGBA String:', blueRgbaString); // Expected: \"rgba(0, 0, 255, 0.4)\"\n\nconst yellowKeyword = colorString.keyword([255, 255, 0]);\nconsole.log('Yellow Keyword:', yellowKeyword); // Expected: \"yellow\"","lang":"javascript","description":"Demonstrates how to parse various CSS color strings into numerical arrays and how to generate CSS color strings from numerical arrays using the imported `colorString` object."},"warnings":[{"fix":"Always install the correct package using `npm install chartjs-color-string`.","message":"The README and GitHub page for `chartjs-color-string` incorrectly instruct users to install `color-string` via `npm install color-string`. `color-string` is a different, unrelated package with a distinct API. Installing the wrong package will lead to module not found errors or unexpected API behavior.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Be aware of the package's maintenance status. For projects requiring active development, newer CSS color features, or more comprehensive color manipulation, consider alternative actively maintained libraries.","message":"This package, `chartjs-color-string`, has not been updated in over seven years (latest version 0.6.0 published March 7, 2019). While functional, it indicates a lack of active development and might not receive updates for newer CSS color specifications or critical bug fixes.","severity":"gotcha","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Uninstall the incorrect package (`npm uninstall color-string`) and install the correct one (`npm install chartjs-color-string`). Ensure your import statements are `import * as colorString from 'chartjs-color-string';` or `const colorString = require('chartjs-color-string');`.","cause":"This error typically occurs if you installed the `color-string` package (the incorrect one as per the README's misleading instructions) instead of `chartjs-color-string`, as `color-string` has a different API (e.g., `colorString.get('#FFF')` returns an object, not an array directly).","error":"TypeError: colorString.getRgb is not a function"},{"fix":"Verify that you have installed `chartjs-color-string` correctly. If not, run `npm install chartjs-color-string`. If `color-string` was installed by mistake, remove it (`npm uninstall color-string`) and install the correct package.","cause":"This error means the package `chartjs-color-string` could not be found. This often happens if you followed the misleading `npm install color-string` instruction in the README, installing the wrong package.","error":"Cannot find module 'chartjs-color-string'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}