Skip to content

Types

ColorSpace

Color spaces supported by Spectrum constructor.

Type Definition

export type ColorSpace = 'hex' | 'hsl' | 'hwb' | 'rgb';

CssNamedColor

A string of a CSS named color, such as 'red', 'blue', 'black' or 'lightseagreen'.
Can be used to initialize a Spectrum instance.

Type Definition

type CssNamedColor = "aliceblue" | "antiquewhite" | "aqua" | ... 145 more ... | "yellowgreen"

HslObj

An HSL object that represents a color in the HSLA (Hue, Saturation, Lightness, Alpha) color space.

KeyDescriptionTypeValid range
hHue (color tone)number[0; 360]
sSaturation (color intensity)number[0; 1]
lLightness (brightness)number[0; 1]
aAlpha channel (opacity)number[0; 1]

Type Definition

type HslObj = {
h: number;
s: number;
l: number;
a: number;
};

HwbObj

An HWB object that represents a color in the HWB (Hue, Whiteness, Blackness, Alpha) color model.

KeyDescriptionTypeValid range
hHue (color tone)number[0; 360]
wWhitenessnumber[0; 1]
bBlacknessnumber[0; 1]
aAlpha channel (opacity)number[0; 1]

Type Definition

type HwbObj = {
h: number;
w: number;
b: number;
a: number;
};

RgbObj

An RGB object that represents a color in the RGBA (Red, Green, Blue, Alpha) color space.

KeyDescriptionTypeValid range
rRednumber[0; 255]
gGreennumber[0; 255]
bBluenumber[0; 255]
aAlpha channel (opacity)number[0; 1]

Type Definition

type RgbObj = {
r: number;
g: number;
b: number;
a: number;
};