Colore JS

Search documentation

Find a function or jump to a section.
v2.0.1

palette

palette generates a Tailwind-style shade ramp from one color. The seed itself sits at the step nearest its OKLCH lightness, so your brand color appears in the ramp exactly.

Example

import { colore } from 'colore-js';
import { palette } from 'colore-js/fn';

colore('#6366f1').palette()[5]?.css(); // '#6366f1'
palette('#6366f1');
// ['#f3f5fe', '#e2e7fc', '#cad2fa', '#a7b2f7', '#828df4', '#6366f1',
//  '#4640c9', '#311aa7', '#1d0d6c', '#11064b', '#040123']
50
100
200
300
400
500
600
700
800
900
950

Syntax

colore(base).palette(options?: PaletteOptions): Color[]
palette(base: ColorInput, options?: PaletteOptions): string[]

Parameters

NameTypeDescription
baseColorInputSeed color to include in the ramp.
options.stepsnumberInteger from 2 to 101. The default is 11 shades, labeled 50, 100, 200 up to 900, and 950. Other counts sample the same lightness curve.

Returns

The method returns Color[]. The function returns CSS strings. The generated shades fit sRGB and preserve the seed alpha and hue. A wide-gamut seed keeps its color coordinates and uses Display P3 or OKLCH output.

Throws

A ColorError for invalid input, an unknown option, or a step count outside the supported range.

Build a compact five-shade ramp

import { palette } from 'colore-js/fn';

palette('#6366f1', { steps: 5 });
// ['#f3f5fe', '#b8c2f9', '#6366f1', '#271389', '#040123']

The nearest step depends on the seed’s lightness, so the brand can fall on a different step when you change the seed.