Edit: after the 1.0 release, the bundle size did increase due to compatibility issues. Rest assured, color2k is still the smallest library of its kind.
color2k is a plain and simple color manipulation library. It can take in colors and change them programmatically giving you the power to write something like this 👇
createPalette(['palevioletred', 'peachpuff', 'papayawhip', 'lavenderblush']);
that can output something like this (CodeSandbox link) 👇
color2k is not the first of its kind. There are many others that do a great job but this one has one goal in mind — a small bundle size.
There are two secrets to color2k's bundle size:
color2k's main secret for a small bundle size is deferring to the browser to parse colors instead of doing it itself. color2k uses
getComputedStyle to parse colors into RGBA. This enables it to accept any color you can pass to as a CSS property value.
color2k was written for the use case of CSS-in-JS. In this context, it doesn't really matter if the color is output as
hsla. color2k only does the conversions it needs in order to manipulate your color and that's it.