Convert a hex color to a darker shade in one line for dynamic UI theming
Generate a smooth color gradient between two colors and retrieve the color at any point along the scale
Use Color Brewer palette sets to create perceptually balanced color schemes for maps and charts
Build logarithmically or quantile-spaced color scales for data visualization dashboards
Chroma.js is a small JavaScript library with no external dependencies for working with colors in code. It handles color conversions, color manipulation such as darkening or lightening a color, and generating smooth color scales between two or more colors. It works in both browsers and Node.js and is available through npm. The most common use is converting colors from one format to another and adjusting them programmatically. For example, you can pass in a hex color code, darken it, and get a new hex value back in a single line. You can also create a gradient scale between two colors and ask for the color at any point along that scale as a percentage. One of the more useful features is the ability to choose which color space is used for interpolation when building a scale. Interpolating in the Lab color space, for instance, produces transitions that look more visually even to human eyes than simple RGB blending does. The library also has built-in support for the Color Brewer palette sets, which are color schemes designed specifically for data visualization work such as maps and charts. Scales can use custom value ranges, quantile bucketing, or logarithmic spacing. The library was written by Gregor Aisch and is released under the BSD license. Versions before 0.4 used a GPL license. An interactive documentation page lets you explore the API and see live examples without writing any code. There is also a static version of the docs in the repository. The README includes a note in the FAQ section addressing why the commit history sometimes goes quiet for long stretches: the author treats the library as stable and focuses on fixes and improvements rather than ongoing cosmetic changes. The project has a Discord channel for contributors and anyone who wants to discuss it.
← gka on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.