Popularity
1.9
Growing
Activity
9.3
-
369
5
7

Description

color2k is a color parsing and manipulation library with the objective of keeping the bundle size as small as possible while still satisfying all of your color manipulation needs in an sRGB space.

The bundle size is currently 2.8kB

Monthly Downloads: 0
Programming language: TypeScript
License: MIT License
Tags: Color     Css     Colors    
Latest version: v1.1.1

color2k alternatives and similar libraries

Based on the "Color" category.
Alternatively, view color2k alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of color2k or a related project?

Add another 'Color' Library

README

color2k bundlephobia github status checks codecov

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

color2k is a color parsing and manipulation library with the objective of keeping the bundle size as small as possible while still satisfying all of your color manipulation needs in an sRGB space.

The bundle size is currently 2.8kB

Size comparison

lib size
polished 11.2kB
chroma-js 13.7kB
color 7.6kB
tinycolor2 5kB
color2k 2.8kB ๐Ÿ˜Ž

Installation

npm i color2k

or

yarn add color2k

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. Simplicity โ€” only handles basic color manipulation functions
  2. Less branching in code โ€”ย only support two color models as outputs, namely rgba and hsla

Why only rgba and hsla as outputs?

This lib was created with the use case of CSS-in-JS in mind. At the end of the day, all that matters is that the browser can understand the color string you gave it as a background-color.

Because only those two color models are supported, we don't have to add code to deal with optional alpha channels or converting to non-browser supported color models (e.g. CMYK).

We believe that this lib is sufficient for all of your color manipulation needs. If we're missing a feature, feel free to open an issue ๐Ÿ˜Ž.

Credits

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

<!-- DOCS-END -->

API and Documentation

Head over to the docs site