Zen Colors easily create perceptual color tints, shades and scales

Library Features

Works with your color

const c = new Color('#6b6a5b');

Effortless color scales

Generate predictable color palettes from a single color with .all(weight) that includes tints and shades.

new Color('#6b6a5b').all(10);

Easy Tints

Mix a base color with white and create a single .tint() or multiple .tints().

new Color('#6b6a5b').tint(10);

Quick Shades

Mix a base color with black and create a single .shade() or multiple .shades().

new Color('#6b6a5b').shades(10);

oklch() by default

Working with modern CSS colors creates predictable color matching aligned with our vision capabilities.

oklch(73% 0.1 161)

Contrast information

Get WCAG contrast information via .contrast(color).

new Color('#6b6a5b').contrast('#fff');

Readable text colors

Use .fg() to quickly get an AA - AAA contrast text color.

new Color('#6b6a5b').fg(); // #fff

Output as strings

Easily output your color scale as oklch / hex / rgb / hsl.

new Color('#6b6a5b')
         .rgbString(); // 'rgb(107 106 91)' 

Output as CSS variables

Output single colors or scales as: --color-{name}-*.

new Color('#6b6a5b').all(10)
         .cssVariablesString('primary');
Demo Features

Fine-tune your color

Click the header swatch to adjust the lightness, chroma and hue of your color to fit your style.

Color scale previews

Preview generated color palettes with tints and shades from a single color.

Export CSS variables

Choose between the 50 … 950 scale, or a scale with tint (-tN) and shade (-sN) keys for your exported color scales.

Tailwind ready

Export color scales as Tailwind CSS ready @theme {} variables for easy use within your Tailwind project.

--color-brand: …;.bg-brand

History saved

Go back in time to your last 20 colors saved in your own browser. Available in the sidebar.

Installation & Usage

Install

Install using npm, pnpm, bun or yarn.

Usage

Library v · MIT

Canvas: new Color(c).all()

.tint(weight)

Lighten toward white in OKLCH by weight percent (default 50).

.shade(weight)

Darken toward black in OKLCH by weight percent (default 50).

.tints(step)

Series of tints at every step percent, including weight 100 (white).

.shades(step)

Series of shades at every step percent, including weight 100 (black).

.all(step)

Full series lightest → base → darkest. This panel uses the global header color & weight ().

.scale(weight)

Basic scale as a flat array — skips pure white/black. Uses the series step control.

.scale(weight, { preset: 'zen' })

Weight-driven keys tN / base / sN — default export vocabulary.

.scale(weight, { preset: 'tailwind' })

Fixed stops 50…950 with the base color at 500.

CSS variables

Export a scale as custom properties for Tailwind @theme, design tokens, or plain CSS. Defaults: preset: 'zen', weight: 10, format: 'oklch', prefix color--color-name-key (e.g. --color-primary-t90).

.cssVariablesString(name)

Zen keys at the default weight — the usual design-token shape: tN / base / sN.

Live output uses series step and name (same control as the Export drawer).

.cssVariablesString(name, { preset: 'tailwind' })

Fixed stops 50…950 with the base at 500. Weight is ignored.

cssVariablesString(colors, name)

Free function: format any Color[] or keyed record you already built. Below uses .all(step) (includes pure white/black as t100 / s100).

format: 'hex'

Values as #rrggbb (also rgb / hsl). Default is oklch.

prefix & format

Change the middle segment (default color) and value syntax together — e.g. --zen-primary-base: rgb(…).

Full options: weight, preset (zen · tailwind · null), format, prefix.

Contrast

Work with two colors: A (palette) and B (compare / surface). Pick which side is the background for .fg and .on previews.

1 · Measure a pair

.contrast(other) reports the WCAG ratio between A and B, pass badges, and which side is darker. Use this for “are these two surfaces different enough?” as well as text checks.

2 · Ink on a surface · .fg

.fg() picks pure black or white. .fg('aa') / .fg('base') / … returns a soft grey (when possible) that meets that level’s minimum ratio on the surface — not only full black/white.

3 · Meet a ratio · .on

.on(ratio, { against }) walks tints and shades of the non-surface color until contrast against the surface hits your target (or best effort). Use this when you want the brand hue to stay, only lighter/darker.

Colors A & B

A · palette

OKLCH · A

B · compare

OKLCH · B

Scale · click to set B

Surface for .fg / .on previews:

.contrast(other)

Measure the pair A vs B — ratio, WCAG badges (by threshold), darker side.

Could not parse A or B.

.fg(level?)

On the surface: no level → pure black/white; with level → soft grey meeting that minimum ratio when possible.

WCAG / UI

Intent

.on(ratio, { against })

Tint or shade the non-surface color until it meets the target against the surface (keeps the hue family).

Need two valid colors.

Scale clarity on surface

Each step of palette A.all(weight) as text on the selected surface. Badge = highest WCAG band met (or FAIL).

Header weight · surface =

Getting started

This playground is a static GitHub Pages demo. The npm package is the library of record.

Concepts

API cheatsheet

Agents / browser JSON

v1 is client-side only (GitHub Pages). Use the mode to build query strings and copy JSON envelopes.

Ops: parse, tint, shade, all, scale, contrast, fg, on, random. See llms.txt.

Credits

License

MIT License

© Copyright Noel Delgado [pixelia.me@gmail.com] (pixelia.me) - inspiration and some concepts

© Copyright 2026 kematzy [kematzy@gmail.com] (github.com/kematzy) - assisted by Grok 4.5 (grok.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Browser JSON API

Static demo helper for agents — not a networked HTTP service. Shareable via query params.