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
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.
Related
- Tailwind v4 colors from a brand color to turn a ramp into CSS tokens
- Palette generator to build and copy a scale from your own color
- generateSystem for semantic roles and both modes
- scale for a ramp between two endpoints