npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hueforge

v1.0.2

Published

Generate perceptually uniform color scales from any CSS color using the OKLCH color space — like Tailwind's palette, for any color you choose.

Readme

hueforge

Generate perceptually uniform color scales from any CSS color — like Tailwind's palette, for any color you choose.

Install

npm install hueforge
# or
yarn add hueforge
# or
pnpm add hueforge

Usage

import { colorScale } from "hueforge";

colorScale("#3b82f6");
// {
//   50:  "#f0f6ff",
//   100: "#dbeafe",
//   200: "#bfdbfe",
//   300: "#93c5fd",
//   400: "#60a5fa",
//   500: "#3b82f6",  ← your color
//   600: "#2563eb",
//   700: "#1d4ed8",
//   800: "#1e40af",
//   900: "#1e3a8a",
//   950: "#172554"
// }

Supported Input Formats

colorScale("#e11d48")                        // hex
colorScale("#f43")                           // shorthand hex
colorScale("rgb(225, 29, 72)")               // rgb
colorScale("rgba(225, 29, 72, 1)")           // rgba
colorScale("hsl(346, 77%, 50%)")             // hsl
colorScale("hsla(346, 77%, 50%, 1)")         // hsla
colorScale("oklch(0.55 0.22 15)")            // oklch
colorScale("red")                            // named CSS color (browser only)

Output Format

By default colorScale returns hex strings. Pass a second argument to change the format:

colorScale("#e11d48", "hex")    // → "#f43f6e"
colorScale("#e11d48", "rgb")    // → "rgb(244, 63, 110)"
colorScale("#e11d48", "hsl")    // → "hsl(346, 89%, 60%)"
colorScale("#e11d48", "oklch")  // → "oklch(0.6463 0.2043 14.87)"

Custom Steps

Pass a third argument to control which steps are generated. Steps are numbers in the range 50–950 and map to positions on the light-to-dark scale (50 = lightest, 950 = darkest).

// Only generate a few steps
colorScale("#3b82f6", "hex", [100, 500, 900]);
// { 100: "#dbeafe", 500: "#3b82f6", 900: "#1e3a8a" }

// Denser scale
colorScale("#3b82f6", "hex", [50, 100, 150, 200, 300, 400, 500]);

// Single step
colorScale("#3b82f6", "hex", [500]);
// { 500: "#3b82f6" }

Duplicate steps are silently deduplicated. Steps outside 50–950 are clamped to the nearest end of the scale.

Type Signatures

export type ColorFormat = "hex" | "rgb" | "hsl" | "oklch";

export type ColorScale = {
  50: string;  100: string; 200: string; 300: string;
  400: string; 500: string; 600: string; 700: string;
  800: string; 900: string; 950: string;
};

// Default steps → fully typed ColorScale
function colorScale(input: string, returnFormat?: ColorFormat): ColorScale;

// Custom steps → Record keyed by the step numbers you passed
function colorScale(input: string, returnFormat: ColorFormat, steps: readonly number[]): Record<number, string>;

Utility Functions

All conversion helpers are exported for direct use.

parseColor(str: string): [r, g, b]

Parses any supported CSS color string into an [r, g, b] tuple (0–255).

import { parseColor } from "hueforge";

parseColor("#3b82f6")            // [59, 130, 246]
parseColor("rgb(59, 130, 246)")  // [59, 130, 246]
parseColor("hsl(217, 91%, 60%)") // [59, 130, 246]

hexToRgb(hex: string): [r, g, b]

Converts a hex color string (#rrggbb or #rgb) to an [r, g, b] tuple.

import { hexToRgb } from "hueforge";

hexToRgb("#3b82f6")  // [59, 130, 246]
hexToRgb("#f00")     // [255, 0, 0]

hslToRgb(h, s, l): [r, g, b]

Converts HSL values to an [r, g, b] tuple. h is 0–360, s and l are 0–100.

import { hslToRgb } from "hueforge";

hslToRgb(217, 91, 60)  // [59, 130, 246]

oklchToRgb(l, c, h): [r, g, b]

Converts OKLCH values to an [r, g, b] tuple. l is 0–1, c is chroma (typically 0–0.4), h is 0–360.

import { oklchToRgb } from "hueforge";

oklchToRgb(0.6239, 0.1752, 255.4)  // [59, 130, 246]

rgbToOklch(r, g, b): [l, c, h]

Converts an [r, g, b] tuple (0–255) to OKLCH.

import { rgbToOklch } from "hueforge";

rgbToOklch(59, 130, 246)  // [0.6239, 0.1752, 255.4]

rgbToHex(r, g, b): string

Converts an [r, g, b] tuple (0–255) to a hex color string.

import { rgbToHex } from "hueforge";

rgbToHex(59, 130, 246)  // "#3b82f6"

rgbToHslString(r, g, b): string

Converts an [r, g, b] tuple (0–255) to an HSL color string.

import { rgbToHslString } from "hueforge";

rgbToHslString(59, 130, 246)  // "hsl(217, 91%, 60%)"

formatColor(r, g, b, format): string

Formats an [r, g, b] tuple into any supported output format.

import { formatColor } from "hueforge";

formatColor(59, 130, 246, "hex")    // "#3b82f6"
formatColor(59, 130, 246, "rgb")    // "rgb(59, 130, 246)"
formatColor(59, 130, 246, "hsl")    // "hsl(217, 91%, 60%)"
formatColor(59, 130, 246, "oklch")  // "oklch(0.6239 0.1752 255.40)"

How It Works

Scales are generated in the OKLCH color space — the same perceptually uniform space used by Tailwind CSS v4 and Radix UI. This means:

  • Step 50 is pure white with the barest hint of hue
  • Step 500 matches your input color
  • Step 950 is a very dark shade
  • Lightness and chroma follow independent power curves so each step feels evenly spaced to the human eye — no muddy mid-tones or grey-ish extremes

License

MIT © Naxrul Ahmed