Introducing Constellation—a color conversion tool that converts your lousy HEX-based base tokens into beautiful, modern color spaces using gamma-correct calculations and proper matrix transformations.
Install
Get started straight away by installing the Constellation package, either locally or globally. The package is less than 25kb.
Install using npm:
bash
# locally
npm i @razorloaf/constellation
# globally
npm i -g @razorloaf/constellation
Features
User Guide: Locate
Locate is powerful if you want to quickly transform a single HEX value into the various color spaces.
Example:
js
What to see support for HSL, CMYK, and other spaces in the future?
User Guide: Transform
The transform function is key when converting entire color files at once. It's smart enough to detect new additions, dark-theme colors, and formats for good housekeeping.
Before:
css
After:
css
Basic Commands
Constellation was made to be deliberatly simple. Run the commands in your terminal and Constellation will do the rest.
Basic transformation:
bash
Output to a different file:
bash
Force regeneration of all colors:
bash
Themes
Constellation detects themes in two ways:
Example:
css
:root {
/* pink - Hex */
--pink-100: #FEF6FA;
--pink-200: #FCE8F2;
/* ...more HEX shades... */
/* pink - Hex (Dark) */
--pink-100-dark: #290A19;
--pink-200-dark: #521432;
/* ...more dark HEX shades... */
}
If you append -dark to your token name Constellation will clean your core css file for good house keeping and developer experience. As you can see we strip -dark from the token name and format for easy theming.
Output:
css
:root {
/* pink - Hex */
--pink-100: #FEF6FA;
--pink-200: #FCE8F2;
/* ...more HEX shades... */
/* pink - Alpha */
--pink-100-alpha: #E2007009;
--pink-200-alpha: #DE006F17;
/* ...more Alpha shades... */
/* pink - OKLCH */
--pink-100-oklch: oklch(98.0% 0.0100 344.9);
--pink-200-oklch: oklch(95.0% 0.0253 345.6);
/* ...more OKLCH shades... */
/* pink - Display-P3 Alpha */
--pink-100-p3a: color(display-p3 0.8889 0 0.4444 / 0.035);
--pink-200-p3a: color(display-p3 0.8696 0 0.4348 / 0.090);
/* ...more P3a shades... */
}
[data-theme="dark"] {
/* pink - Hex (Dark) */
--pink-100: #290A19;
--pink-200: #521432;
/* ...more dark HEX shades... */
/* pink - Alpha (Dark) */
--pink-100-alpha: #F300571A;
--pink-200-alpha: #F9198647;
/* ...more dark Alpha shades... */
/* pink - OKLCH (Dark) */
--pink-100-oklch: oklch(20.4% 0.0556 353.0);
--pink-200-oklch: oklch(30.6% 0.0970 354.7);
/* ...more dark OKLCH shades... */
/* pink - Display-P3 Alpha (Dark) */
--pink-100-p3a: color(display-p3 0.9576 0 0.3406 / 0.102);
--pink-200-p3a: color(display-p3 0.976 0.0989 0.5233 / 0.277);
/* ...more dark P3a shades... */
}
Footnotes
This open source package is being maintained by Joshua Hoy.
Licensed under MIT. See LICENSE file for complete terms.
While attribution is appreciated, it's not required for implementation in commercial projects.
Mid Engineering © 2025