Skip to content

@jsvision/core / ramp

Function: ramp()

ramp(seed, steps): Color[]

Defined in: color/ramp.ts:105

Generate steps perceptually-even shades of a seed color, dark → light.

The shades share the seed's hue and chroma while their OKLab lightness sweeps evenly from dark to light, so they read as a coherent tonal ramp (useful for deriving raised/sunken surfaces or hover states from one brand color).

Parameters

seed

Color

A resolvable color (hex or named) — not 'default'.

steps

number

How many shades to return (≥ 1). 1 returns the seed itself, round-tripped.

Returns

Color[]

steps #rrggbb strings, ordered darkest → lightest.

Throws

InvalidColorError when seed is 'default' or otherwise unresolvable.

Example

ts
import { ramp } from '@jsvision/core';

ramp('#3b82f6', 5); // 5 blues from dark to light, evenly spaced to the eye