Types
Type Aliasesβ
AdaptivePaletteOptionsβ
AdaptivePaletteOptions: {
backgroundColor
: {dark
:ColorToken
;light
:ColorToken
; };colorBlind
:boolean
; }
Type declarationβ
backgroundColor?β
optional
backgroundColor: {dark
:ColorToken
;light
:ColorToken
; }
backgroundColor.dark?β
optional
dark:ColorToken
backgroundColor.light?β
optional
light:ColorToken
colorBlind?β
optional
colorBlind:boolean
Defined inβ
BiasedHuesβ
BiasedHues:
"red-purple"
|"yellow-red"
|"green-yellow"
|"blue-green"
|"purple-blue"
Hue biases as seen when transitioning from one hue to another on the color wheel (Lch).
Defined inβ
Collectionβ
Collection:
ColorToken
[] |Map
<any
,ColorToken
> |Set
<ColorToken
> |object
Any collection with enumerable keys that can be used to iterate through it to get the values which are expected to be valid color tokens.
Defined inβ
ColorFamilyβ
ColorFamily:
"red"
|"green"
|"blue"
|"yellow"
|"red"
|"purple"
|"gray"
The basic color families (including gray).
Defined inβ
ColorOptionsβ
ColorOptions: {
alpha
:number
;colorspace
:Colorspaces
;contrast
:number
;darkMode
:ColorToken
;implicitReturn
:boolean
;lightMode
:ColorToken
;lightness
:number
;luminance
:number
;mode
:Colorspaces
;saturation
:number
;temp
:number
; }
Properties on an instance of the Color
class. Some of these properties have corresponding methods.
Type declarationβ
alpha?β
optional
alpha:number
colorspace?β
optional
colorspace:Colorspaces
contrast?β
optional
contrast:number
darkMode?β
optional
darkMode:ColorToken
implicitReturn?β
optional
implicitReturn:boolean
lightMode?β
optional
lightMode:ColorToken
lightness?β
optional
lightness:number
luminance?β
optional
luminance:number
mode?β
optional
mode:Colorspaces
saturation?β
optional
saturation:number
temp?β
optional
temp:number
Defined inβ
ColorTokenβ
ColorToken:
number
|ColorTuple
|boolean
|string
|object
Any recognizable color token.
Defined inβ
ColorTupleβ
ColorTuple: (
number
|string
)[]
An array of channel values for a color token with the mode
(first element of type string
) and alpha
(last element of type number
in the [0,1] range) being optional.
It can also be in different variants as shown below:
Exampleβ
// The first element can either be a string `mode` which denotes the colorspace the channel values are valid in.
const colorTuple = ['rgb',0.1,0.5,0.8]
const colorTupleWithAlpha = ['rgb',0.1,0.5,0.8,0.5]
const colorTupleWithAlphaButNoMode = [0.1,0.5,0.8,0.5]
const colorTupleWithNoAlphaAndMode = [0.1,0.5,0.8]
When omitting the `mode` from the color tuple, be sure to specify the `srcMode` option in when passing it to `token()` or any function that has access to `TokenOptions`.
Defined inβ
Colorspacesβ
Colorspaces:
"lab"
|"lab65"
|"rgb"
|"lch"
|"lch65"
|"xyz65"
|"xyz"
|"lrgb"
|"hsv"
The colorspace
or mode
to use.
Defined inβ
DeficiencyOptionsβ
DeficiencyOptions: {
kind
:DeficiencyType
;severity
:number
;token
:TokenOptions
; }
Overrides to specify the type of color blindness and filter intensity.
Type declarationβ
kind?β
optional
kind:DeficiencyType
The type of color vision deficiency. Default is 'red'
severity?β
optional
severity:number
The intensity of the filter. The exepected value is between [0,1]. Default is 0.1
.
token?β
optional
token:TokenOptions
Specify the parsing behaviour and change output type of the ColorToken
.
Defined inβ
DeficiencyTypeβ
DeficiencyType:
"red"
|"blue"
|"green"
|"monochromacy"
The type of color vision defeciency.
Defined inβ
DiscoverOptionsβ
DiscoverOptions: {
colorspace
:Colorspaces
;kind
:SchemeType
;maxDistance
:number
;minDistance
:number
;token
:TokenOptions
; }
Options for the discover()
palette generator function.
Type declarationβ
colorspace?β
optional
colorspace:Colorspaces
The colorspace to retrieve channel values from.
kind?β
optional
kind:SchemeType
The palette type to return.
Default is undefined
maxDistance?β
optional
maxDistance:number
The minimum distance between colors. May affect finally palette results
Default is the jnd
internal constant.
minDistance?β
optional
minDistance:number
The minimum distance between colors. May affect finally palette results. Default is 0
token?β
optional
token:TokenOptions
Specify the parsing behaviour and change output type of the ColorToken
.
Defined inβ
DistributionOptionsβ
DistributionOptions:
Pick
<InterpolatorOptions
,"hueFixup"
> & {colorspace
:Colorspaces
;excludeAchromatic
:boolean
;excludeSelf
:boolean
;extremum
:"min"
|"max"
|"mean"
;factor
:Factor
|Factor
[];token
:TokenOptions
; }
Override options for factor distributed palettes.
Type declarationβ
colorspace?β
optional
colorspace:Colorspaces
The colorspace to distribute the specified factor in. Defaults to lch
when the passed in mode has no 'chroma' | 'hue' | 'lightness'
channel
excludeAchromatic?β
optional
excludeAchromatic:boolean
Exclude grayscale colors from the distribution operation. Default is false
excludeSelf?β
optional
excludeSelf:boolean
Exclude the color with the specified extremum
from the distribution operation. Default is false
extremum?β
optional
extremum:"min"
|"max"
|"mean"
The extreme end for the factor
we wish to distribute. If mean
is picked, it will map the average
value of that factor in the passed in collection.
factorβ
The factor(s) to distribute amongst each color token in the passed in collection.
token?β
optional
token:TokenOptions
Specify the parsing behaviour and change output type of the ColorToken
.
Defined inβ
DivergingSchemeβ
DivergingScheme:
"Spectral"
|"RdYlGn"
|"RdBu"
|"PiYG"
|"PRGn"
|"RdYlBu"
|"BrBG"
|"RdGy"
|"PuOr"
The diverging
color scheme in the ColorBrewer colormap.
Defined inβ
EarthtoneOptionsβ
EarthtoneOptions:
InterpolatorOptions
& {earthtones
:"light-gray"
|"silver"
|"sand"
|"tupe"
|"mahogany"
|"brick-red"
|"clay"
|"cocoa"
|"dark-brown"
|"dark"
; }
Options for the earthtone()
palette generator function.
Type declarationβ
earthtones?β
optional
earthtones:"light-gray"
|"silver"
|"sand"
|"tupe"
|"mahogany"
|"brick-red"
|"clay"
|"cocoa"
|"dark-brown"
|"dark"
- earthtone The earthtone to interpolate with.
Defined inβ
Fact<F>β
Fact<
F
>:F
extendstrue
? {color
:ColorToken
;factor
:number
; } :number
The value of the factor
being queried usually a number but can also be falsy like NaN
for edge cases or an object with the value of the factor and the color token associated with it.
Type Parametersβ
β’ F
Defined inβ
Factorβ
Factor:
"luminance"
|"chroma"
|"contrast"
|"distance"
|"lightness"
|"hue"
The color property being queried.
Defined inβ
FilterByOptionsβ
FilterByOptions: {
against
:ColorToken
;colorspace
:Colorspaces
;factor
:Factor
|Factor
[];ranges
: { [F in Factor]?: (number | string)[] } | (number
|string
)[]; }
Overrides for setting filtering criterion, expected ranges and other behaviour.
Type declarationβ
against?β
optional
against:ColorToken
The color to compare the factor
with. All the factor
s are calculated between this color and the ones in the colors array. Only works for the 'distance'
and 'contrast'
factor.
colorspace?β
optional
colorspace:Colorspaces
The mode colorspace to perform the sorting operation in. It is ignored when the factor is 'luminance' | 'contrast' | 'distance'
.
factor?β
The factor to use as a filtering criterion.
Default is 'hue'
ranges?β
optional
ranges: { [F in Factor]?: (number | string)[] } | (number
|string
)[]
The targeted start and end ranges for the factor:
- If a single
factor
is specified,ranges
is expected to be an array. - If multiple
factor
s are specified thenranges
is expected to be an object with the factor(s) as keys and an array of the start and end as values. - The start and end values can be either numbers or string expressions. The end value is optional but the range value(s) are expected to be in an array.
Defined inβ
HueshiftOptionsβ
HueshiftOptions:
Pick
<InterpolatorOptions
,"colorspace"
|"easingFn"
|"num"
|"tokenOptions"
> & {hueStep
:number
;maxLightness
:number
;minLightness
:number
; }
Options for the hueshift()
palette generator function.
Type declarationβ
hueStep?β
optional
hueStep:number
The hue angle to increment each iteration with.
maxLightness?β
optional
maxLightness:number
maxLightness Maximum lightness value (range 0-100).
minLightness?β
optional
minLightness:number
- minLightness Minimum lightness value (range 0-100).
Defined inβ
InterpolatorOptionsβ
InterpolatorOptions: {
closed
:boolean
;colorspace
:Colorspaces
;easingFn
: (t
) =>number
;hueFixup
:"longer"
|"shorter"
;kind
:"basis"
|"monotone"
|"natural"
;num
:number
;stops
:number
[];tokenOptions
:TokenOptions
; }
Options for customizing the color interpolator behaviour. It is extended by some palette utilities
Type declarationβ
closed?β
optional
closed:boolean
Optional parameter to return the 'closed'
variant of the 'kind' of interpolation method which can be useful for cyclical color scales. Default is false
colorspace?β
optional
colorspace:Colorspaces
The colorspace to perform the color space in. Prefer uniform color spaces for better results such as Lch or Jch.
easingFn()?β
optional
easingFn: (t
) =>number
The easing function to use.
Parametersβ
β’ t: number
Any value between 0 and 1
Returnsβ
number
A number.
hueFixup?β
optional
hueFixup:"longer"
|"shorter"
The type of hue fixup to apply to the hue channels during interpolation.
kind?β
optional
kind:"basis"
|"monotone"
|"natural"
The type of the spline interpolation method. Default is basis.
num?β
optional
num:number
The amount of samples to return in the result collection.
stops?β
optional
stops:number
[]
The positions of color stops to use during interpolation. Each number in the array is assigned to the colors in the collection according to the order the colors are passed in.
Plain objects as collects do not remember insertion order so it may return unexpected results. Preferably use an ArrayLike or Map object.
tokenOptions?β
optional
tokenOptions:TokenOptions
Specify the parsing behaviour and change output type of the ColorToken
.
Defined inβ
Orderβ
Order:
"asc"
|"desc"
The order to insert elements back into the result collection either ascending ('asc'
) or descending ('desc'
).
Defined inβ
PairedSchemeOptionsβ
PairedSchemeOptions:
InterpolatorOptions
& {hueStep
:number
;via
:Tone
; }
Options for the pair()
palette generator function.
Type declarationβ
hueStep?β
optional
hueStep:number
The hue angle to increment each iteration with.
via?β
optional
via:Tone
The color to pass through during interpolation.
Defined inβ
QualitativeSchemeβ
QualitativeScheme:
"Set2"
|"Accent"
|"Set1"
|"Set3"
|"Dark2"
|"Paired"
|"Pastel2"
|"Pastel1"
The qualitative
color scheme in the ColorBrewer colormap.
Defined inβ
ScaleValuesβ
ScaleValues:
"050"
|"100"
|"200"
|"300"
|"400"
|"500"
|"600"
|"700"
|"800"
|"900"
|"950"
The value of the Tailwind color.
Defined inβ
SchemeOptionsβ
SchemeOptions:
Pick
<InterpolatorOptions
,"easingFn"
|"colorspace"
> & {kind
:SchemeType
|SchemeType
[];token
:TokenOptions
; }
Options for the scheme()
palette generator function.
Type declarationβ
kind?β
optional
kind:SchemeType
|SchemeType
[]
token?β
optional
token:TokenOptions
Defined inβ
SchemeTypeβ
SchemeType:
"analogous"
|"triadic"
|"tetradic"
|"complementary"
The scheme to use when creating base palettes.
Defined inβ
SequentialSchemeβ
SequentialScheme:
"OrRd"
|"PuBu"
|"BuPu"
|"Oranges"
|"BuGn"
|"YlOrBr"
|"YlGn"
|"Reds"
|"RdPu"
|"Greens"
|"YlGnBu"
|"Purples"
|"GnBu"
|"Greys"
|"YlOrRd"
|"PuRd"
|"Blues"
|"PuBuGn"
|"Viridis"
The sequential
color scheme in the ColorBrewer colormap.
Defined inβ
SortByOptionsβ
SortByOptions: {
against
:ColorToken
;colorspace
:Colorspaces
;factor
:Factor
;order
:"asc"
|"desc"
;relative
:boolean
; }
Options for specifying sorting conditions.
Type declarationβ
against?β
optional
against:ColorToken
The color to compare the factor
with.
All the factor
s are calculated between this color and the ones in the colors array.
Only works for the 'distance'
and 'contrast'
factor.
colorspace?β
optional
colorspace:Colorspaces
The colorspace to perform the sorting operation in. It is ignored when the factor is 'luminance' | 'contrast' | 'distance'
.
factor?β
optional
factor:Factor
The factor to use for sorting the colors.
order?β
optional
order:"asc"
|"desc"
The arrangement order of the colors either asc | desc
. Default is ascending (asc
).
relative?β
optional
relative:boolean
Use the against
comparison color when ordering the color tokens.
It has no effect on contrast
and distance
factors because they're already relative.
Defined inβ
Statsβ
Stats:
{ [T in Factor]: Object & Object }
The default structure of a Stats
object as returned by stats()
when invoked with default options
.
Defined inβ
StatsOptionsβ
StatsOptions: {
against
:ColorToken
;colorspace
:Colorspaces
;factor
:Factor
|Factor
[];relative
:boolean
; }
Optional parameters to specify how the data should be computed.
Type declarationβ
against?β
optional
against:ColorToken
The color to compare the factor
with. All the factor
s are calculated between this color and the ones in the colors array. Only works for the 'distance'
and 'contrast'
factor.
colorspace?β
optional
colorspace:Colorspaces
The colorspace to perform the sorting operation in. It is ignored when the factor is 'luminance' | 'contrast' | 'distance'
.
factor?β
relative?β
optional
relative:boolean
Choose whether to use the against
color token for factors that support it as an overload (that is, all factors except distance
and `contrast)
Defined inβ
Tailwindβ
Tailwind:
"indigo"
|"gray"
|"zinc"
|"neutral"
|"stone"
|"red"
|"orange"
|"amber"
|"yellow"
|"lime"
|"green"
|"emerald"
|"teal"
|"sky"
|"blue"
|"violet"
|"purple"
|"fuchsia"
|"pink"
|"rose"
Color families in the default TailwindCSS palette.
Defined inβ
TokenOptionsβ
TokenOptions: {
kind
:"num"
|"arr"
|"obj"
|"str"
;normalizeRgb
:boolean
;numType
:"expo"
|"hex"
|"oct"
|"bin"
;omitAlpha
:boolean
;omitMode
:boolean
;srcMode
:Colorspaces
;targetMode
:Colorspaces
; }
Overrides to customize the parsing and output behaviour.
Type declarationβ
kind?β
optional
kind:"num"
|"arr"
|"obj"
|"str"
The type of color token to return. Default is 'str'
.
normalizeRgb?β
optional
normalizeRgb:boolean
If true
and the passed in color token is an array or plain object and in the srcMode
of 'rgb'
or 'lrgb'
,
it will have all channels normalized back to [0,1] range if any of the channe values is beyond 1.
This can help the parser to recognize RGB colors in the [0,255] range which Culori doesn't handle.
Default is true
.
numType?β
optional
numType:"expo"
|"hex"
|"oct"
|"bin"
The type of number to return. Only valid if kind is set to 'number'
. Default is 'literal'
omitAlpha?β
optional
omitAlpha:boolean
If the kind
is set to 'arr'
it will remove the alpha channel value from color tuple. Default is false
.
omitMode?β
optional
omitMode:boolean
If the kind
is set to 'arr'
it will remove the mode string from color tuple. Default is false
.
srcMode?β
optional
srcMode:Colorspaces
The mode in which the channel values are valid in. It is used for color arrays if they have the colorspace
string ommitted. Default is 'rgb'
.
targetMode?β
optional
targetMode:Colorspaces
The colorspace in which to return the color object or array in. Default is 'lch'
.
Defined inβ
Toneβ
Tone:
"light"
|"dark"
The tone to use.