DaxSoft / color2k

a color parsing and manipulation lib served in 2kB or less

Home Page:https://color2k.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

lib size link
polished 11.2kB repo
chroma-js 13.7kB repo
color 7.6kB repo
tinycolor2 5kB repo
color2k 1.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

About

a color parsing and manipulation lib served in 2kB or less

https://color2k.com/


Languages

Language:TypeScript 80.0%Language:JavaScript 16.5%Language:CSS 3.5%