@santana-org/colors
v0.3.0
Published
Minimal TypeScript color utility library with parsing, conversion, and fluent manipulation
Maintainers
Readme
📦 Install
npm install @santana-org/colors
pnpm add @santana-org/colors🚀 Usage
import { color } from "@santana-org/colors"
color("#ff0000").lighten(0.2).toHex() // "#ff6666"
color("rgb(255,0,0)").toHsl() // "hsl(0, 100%, 50%)"
color("hsl(0,100%,50%)").mix("#0000ff").toHex() // "#7f007f"📖 API
color(input)
Accepts #hex, #hexa, rgb(), rgba(), hsl(), hsla(). Returns an immutable, chainable color object.
| Method | Description |
|---|---|
| lighten(n) / darken(n) | Adjust lightness by n (0–1) |
| saturate(n) / desaturate(n) | Adjust saturation by n (0–1) |
| invert() | Invert the color |
| mix(color, weight?) | Mix with another color |
| alpha(n) | Set alpha channel |
| toHex() / toHexa() | Output as hex string |
| toRgb() / toRgba() | Output as rgb() string |
| toHsl() / toHsla() | Output as hsl() string |
| toRgbObject() / toHslObject() | Output as plain object |
| toState() / toString() | Internal state / default string |
🔧 Low-level helpers
import { parseHex, rgbToHsl, lighten, mix, paint } from "@santana-org/colors"- Parsing —
parseColor,parseHex,parseRgb,parseHsl - Conversion —
rgbToHex,rgbToHsl,hslToRgb - Manipulation —
lighten,darken,saturate,desaturate,invert,mix,withAlpha - ANSI terminal —
paint,ansi,dim,gray,cyan,green,yellow,red,magenta
🏗️ Design
- Zero dependencies — small, predictable, no surprises.
- Immutable API — every operation returns a new instance.
- Modular internals — parsing, conversion, and manipulation are independent.
- ANSI support — built-in terminal helpers used by
@santana-org/logger.
📄 License
MIT © santana-org
