sass:color
- Dart Sass
- since 1.23.0
- LibSass
- ✗
- Ruby Sass
- ✗
color.adjust($color,
$red: null, $green: null, $blue: null,
$hue: null, $saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
adjust-color(...) //=> color - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Increases or decreases one or more properties of $color by fixed amounts.
Adds the value passed for each keyword argument to the corresponding property of the color, and returns the adjusted color. It’s an error to specify an RGB property ($red, $green, and/or $blue) at the same time as an HSL property ($hue, $saturation, and/or $lightness), or either of those at the same time as an HWB property ($hue, $whiteness, and/or $blackness).
All optional arguments must be numbers. The $red, $green, and $blue arguments must be unitless and between -255 and 255 (inclusive). The $hue argument must have either the unit deg or no unit. The $saturation, $lightness, $whiteness, and $blackness arguments must be between -100% and 100% (inclusive), and may not be unitless. The $alpha argument must be unitless and between -1 and 1 (inclusive).
See also:
color.scale()for fluidly scaling a color’s properties.color.change()for setting a color’s properties.
adjust-hue($color, $degrees) //=> color Increases or decreases $color‘s hue.
The $hue must be a number between -360deg and 360deg (inclusive) to add to $color’s hue. It may be unitless but it may not have any unit other than deg.
See also color.adjust(), which can adjust any property of a color.
⚠️ Heads up!
Because adjust-hue() is redundant with adjust(), it’s not included directly in the new module system. Instead of adjust-hue($color, $amount), you can write color.adjust($color, $hue: $amount).
color.alpha($color)
alpha($color)
opacity($color) //=> number Returns the alpha channel of $color as a number between 0 and 1.
As a special case, this supports the Internet Explorer syntax alpha(opacity=20), for which it returns an unquoted string.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.blue()for getting a color’s blue channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.
color.blackness($color) //=> number - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Returns the HWB blackness of $color as a number between 0% and 100%.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.alpha()for getting a color’s alpha channel.
color.blue($color)
blue($color) //=> number Returns the blue channel of $color as a number between 0 and 255.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
color.change($color,
$red: null, $green: null, $blue: null,
$hue: null, $saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
change-color(...) //=> color - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Sets one or more properties of a color to new values.
Uses the value passed for each keyword argument in place of the corresponding property of the color, and returns the changed color. It’s an error to specify an RGB property ($red, $green, and/or $blue) at the same time as an HSL property ($hue, $saturation, and/or $lightness), or either of those at the same time as an HWB property ($hue, $whiteness, and/or $blackness).
All optional arguments must be numbers. The $red, $green, and $blue arguments must be unitless and between 0 and 255 (inclusive). The $hue argument must have either the unit deg or no unit. The $saturation, $lightness, $whiteness, and $blackness arguments must be between 0% and 100% (inclusive), and may not be unitless. The $alpha argument must be unitless and between 0 and 1 (inclusive).
See also:
color.scale()for fluidly scaling a color’s properties.color.adjust()for adjusting a color’s properties by fixed amounts.
color.complement($color)
complement($color) //=> color Returns the RGB complement of $color.
This is identical to color.adjust($color, $hue: 180deg).
darken($color, $amount) //=> color Makes $color darker.
The $amount must be a number between 0% and 100% (inclusive). Decreases the HSL lightness of $color by that amount.
⚠️ Heads up!
The darken() function decreases lightness by a fixed amount, which is often not the desired effect. To make a color a certain percentage darker than it was before, use color.scale() instead.
Because darken() is usually not the best way to make a color darker, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, darken($color, $amount) can be written color.adjust($color, $lightness: -$amount).
desaturate($color, $amount) //=> color Makes $color less saturated.
The $amount must be a number between 0% and 100% (inclusive). Decreases the HSL saturation of $color by that amount.
⚠️ Heads up!
The desaturate() function decreases saturation by a fixed amount, which is often not the desired effect. To make a color a certain percentage less saturated than it was before, use color.scale() instead.
Because desaturate() is usually not the best way to make a color less saturated, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, desaturate($color, $amount) can be written color.adjust($color, $saturation: -$amount).
color.grayscale($color)
grayscale($color) //=> color Returns a gray color with the same lightness as $color.
This is identical to color.change($color, $saturation: 0%).
color.green($color)
green($color) //=> number Returns the green channel of $color as a number between 0 and 255.
See also:
color.red()for getting a color’s red channel.color.blue()for getting a color’s blue channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
color.hue($color)
hue($color) //=> number Returns the hue of $color as a number between 0deg and 360deg.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.blue()for getting a color’s blue channel.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
color.hwb($hue $whiteness $blackness)
color.hwb($hue $whiteness $blackness / $alpha)
color.hwb($hue, $whiteness, $blackness, $alpha: 1) //=> color - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Returns a color with the given hue, whiteness, and blackness and the given alpha channel.
The hue is a number between 0deg and 360deg (inclusive). The whiteness and blackness are numbers between 0% and 100% (inclusive). The hue may be unitless, but the whiteness and blackness must have unit %. The alpha channel can be specified as either a unitless number between 0 and 1 (inclusive), or a percentage between 0% and 100% (inclusive).
⚠️ Heads up!
Sass’s special parsing rules for slash-separated values make it difficult to pass variables for $blackness or $alpha when using the color.hwb($hue $whiteness $blackness / $alpha) signature. Consider using color.hwb($hue, $whiteness, $blackness, $alpha) instead.
color.ie-hex-str($color)
ie-hex-str($color) //=> unquoted string Returns an unquoted string that represents $color in the #AARRGGBB format expected by Internet Explorer’s -ms-filter property.
color.invert($color, $weight: 100%)
invert($color, $weight: 100%) //=> color Returns the inverse or negative of $color.
The $weight must be a number between 0% and 100% (inclusive). A higher weight means the result will be closer to the negative, and a lower weight means it will be closer to $color. Weight 50% will always produce #808080.
lighten($color, $amount) //=> color Makes $color lighter.
The $amount must be a number between 0% and 100% (inclusive). Increases the HSL lightness of $color by that amount.
⚠️ Heads up!
The lighten() function increases lightness by a fixed amount, which is often not the desired effect. To make a color a certain percentage lighter than it was before, use scale() instead.
Because lighten() is usually not the best way to make a color lighter, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, lighten($color, $amount) can be written adjust($color, $lightness: $amount).
color.lightness($color)
lightness($color) //=> number Returns the HSL lightness of $color as a number between 0% and 100%.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.blue()for getting a color’s blue channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
color.mix($color1, $color2, $weight: 50%)
mix($color1, $color2, $weight: 50%) //=> color Returns a color that’s a mixture of $color1 and $color2.
Both the $weight and the relative opacity of each color determines how much of each color is in the result. The $weight must be a number between 0% and 100% (inclusive). A larger weight indicates that more of $color1 should be used, and a smaller weight indicates that more of $color2 should be used.
opacify($color, $amount)
fade-in($color, $amount) //=> color Makes $color more opaque.
The $amount must be a number between 0 and 1 (inclusive). Increases the alpha channel of $color by that amount.
⚠️ Heads up!
The opacify() function increases the alpha channel by a fixed amount, which is often not the desired effect. To make a color a certain percentage more opaque than it was before, use scale() instead.
Because opacify() is usually not the best way to make a color more opaque, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, opacify($color, $amount) can be written adjust($color, $alpha: -$amount).
color.red($color)
red($color) //=> number Returns the red channel of $color as a number between 0 and 255.
See also:
color.green()for getting a color’s green channel.color.blue()for getting a color’s blue channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
saturate($color, $amount)
saturate($color, $amount) //=> color Makes $color more saturated.
The $amount must be a number between 0% and 100% (inclusive). Increases the HSL saturation of $color by that amount.
⚠️ Heads up!
The saturate() function increases saturation by a fixed amount, which is often not the desired effect. To make a color a certain percentage more saturated than it was before, use scale() instead.
Because saturate() is usually not the best way to make a color more saturated, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, saturate($color, $amount) can be written adjust($color, $saturation: $amount).
color.saturation($color)
saturation($color) //=> number Returns the HSL saturation of $color as a number between 0% and 100%.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.blue()for getting a color’s blue channel.color.hue()for getting a color’s hue.color.lightness()for getting a color’s lightness.color.whiteness()for getting a color’s whiteness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.
color.scale($color,
$red: null, $green: null, $blue: null,
$saturation: null, $lightness: null,
$whiteness: null, $blackness: null,
$alpha: null)
scale-color(...) //=> color - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Fluidly scales one or more properties of $color.
Each keyword argument must be a number between -100% and 100% (inclusive). This indicates how far the corresponding property should be moved from its original position towards the maximum (if the argument is positive) or the minimum (if the argument is negative). This means that, for example, $lightness: 50% will make all colors 50% closer to maximum lightness without making them fully white.
It’s an error to specify an RGB property ($red, $green, and/or $blue) at the same time as an HSL property ($saturation, and/or $lightness), or either of those at the same time as an HWB property ($whiteness, and/or $blackness).
See also:
color.adjust()for changing a color’s properties by fixed amounts.color.change()for setting a color’s properties.
transparentize($color, $amount)
fade-out($color, $amount) //=> color Makes $color more transparent.
The $amount must be a number between 0 and 1 (inclusive). Decreases the alpha channel of $color by that amount.
⚠️ Heads up!
The transparentize() function decreases the alpha channel by a fixed amount, which is often not the desired effect. To make a color a certain percentage more transparent than it was before, use color.scale() instead.
Because transparentize() is usually not the best way to make a color more transparent, it’s not included directly in the new module system. However, if you have to preserve the existing behavior, transparentize($color, $amount) can be written color.adjust($color, $alpha: -$amount).
color.whiteness($color) //=> number - Dart Sass
- since 1.28.0
- LibSass
- ✗
- Ruby Sass
- ✗
Returns the HWB whiteness of $color as a number between 0% and 100%.
See also:
color.red()for getting a color’s red channel.color.green()for getting a color’s green channel.color.hue()for getting a color’s hue.color.saturation()for getting a color’s saturation.color.lightness()for getting a color’s lightness.color.blackness()for getting a color’s blackness.color.alpha()for getting a color’s alpha channel.