1.0.0-rc.3 โ€ข Published 4 years ago

@color2k/node v1.0.0-rc.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

color2k ยท https://badgen.net/bundlephobia/minzip/color2k

a color parsing and manipulation lib served in 2kB or less (1.4kB to be more precise)

color2k is a color parsing and manipulation library with the objective of keeping the bundle size as small as possible.

The bundle size is currently 1.4kB

Size comparison

libsizelink
polished11.2kBrepo
chroma-js13.7kBrepo
color7.6kBrepo
tinycolor25kBrepo
color2k1.4kB๐Ÿ˜Ž

Installation

npm i --save color2k

If you need to server-side render any colors, you also need to install the node/ssr compatibility package.

# only needed in SSR environments (e.g. gatsby, next.js)
npm i --save @color2k/node

Usage

import { darken, transparentize } from 'color2k';

// e.g.
darken('blue', 0.1);
transparentize('red', 0.5);

How so small?

There are two secrets that keep this lib especially small:

  1. defer to the browser to parse colors via canvas
  2. small API footprint ๐Ÿคทโ€โ™€๏ธ

Credits

Heavy credits goes to polished.js and sass. Much of the implementation of this lib is copied from polished!

API and Documentation

Head over to the docs site