rgb(51, 102, 153)hsl(210, 50%, 40%)All manipulation methods modify the instance in place and return this, supporting method chaining. If you need to preserve the original color, call .clone() first.
rgb(51, 102, 153)hsl(210, 50%, 40%)rgb(71, 133, 194)hsl(210, 50%, 52%)rgb(92, 133, 173)hsl(210, 33%, 52%)rgb(92, 133, 173)hsl(210, 33%, 52%)import xcolor from '@xpyjs/color'
const original = xcolor('#336699').alpha(1)
original.clone().lighten(20).toRgbString()
original.clone().brighten(20).toRgbString()
original.clone().tint(20).toRgbString()Move HSL lightness toward white across the remaining range. amount is the percentage of the distance from the current lightness to 100% (0–100), default 10; 50 moves halfway and 100 always produces white.
xcolor('#ff0000').lighten(20).toHex() // '#ff3333'Move HSL lightness toward black across the current range. amount is the percentage of the distance from the current lightness to 0% (0–100), default 10; 50 moves halfway and 100 always produces black. Equivalent to lighten(-amount).
xcolor('#ff0000').darken(20).toHex() // '#cc0000'Push each channel toward 255 in RGB space. Default 10, range 0–100.
xcolor('#ff0000').brighten(50).toHex() // '#ff8080'Increase HSL saturation. Default 10, range 0–100.
xcolor('#bf4040').saturate(40).toHex() // '#f20d0d'Decrease HSL saturation. Default 10.
xcolor('#ff0000').desaturate(50).toHex() // '#bf4040'Fully desaturate, equivalent to desaturate(100).
Alias: greyscale()
xcolor('#ff0000').grayscale().toHex() // '#808080'Rotate the hue on the HSL color wheel. Supports positive and negative values, automatically wraps at 360°.
Alias: rotate()
xcolor('#ff0000').spin(120).toHex() // '#00ff00'
xcolor('#ff0000').spin(-120).toHex() // '#0000ff'Invert each RGB channel (255 - channel), alpha remains unchanged.
Alias: invert()
xcolor('#ff0000').negate().toHex() // '#00ffff'Decrease opacity. Alpha is reduced by amount / 100, default 10.
Alias: fadeOut()
xcolor('#ff0000').fade(50).alpha() // 0.5Increase opacity. Alpha is increased by amount / 100, default 10.
Alias: fadeIn()
xcolor('rgba(255,0,0,0.5)').opaquer(30).alpha() // 0.8Linearly mix with another color in RGB space. amount is the weight of the target color (0–100), default 50.
xcolor('#ff0000').mix('#0000ff', 50).toHex() // '#800080'Mix with white. amount is the weight of white (0–100), default 50.
xcolor('#ff0000').tint(50).toHex() // '#ff8080'Mix with black. amount is the weight of black (0–100), default 50.
xcolor('#ff0000').shade(50).toHex() // '#800000'| Method | Param | Default | Returns | Alias |
|---|---|---|---|---|
lighten(amount?) | 0–100 | 10 | this | — |
darken(amount?) | 0–100 | 10 | this | — |
brighten(amount?) | 0–100 | 10 | this | — |
saturate(amount?) | 0–100 | 10 | this | — |
desaturate(amount?) | 0–100 | 10 | this | — |
grayscale() | — | — | this | greyscale() |
spin(degrees) | any number | — | this | rotate() |
negate() | — | — | this | invert() |
fade(amount?) | 0–100 | 10 | this | fadeOut() |
opaquer(amount?) | 0–100 | 10 | this | fadeIn() |
mix(color, amount?) | 0–100 | 50 | this | — |
tint(amount?) | 0–100 | 50 | this | — |
shade(amount?) | 0–100 | 50 | this | — |