YouTip LogoYouTip

Sass Color Func

Sass Functions Sass functions

\n\n

Sass color functions can be divided into three parts: color setting, color getting, and color operations.

\n\n

The following table lists Sass color functions:

\n\n

Sass Color Setting

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
FunctionDescription & Example
rgb(red, green, blue)Creates a Red-Green-Blue (RGB) color. Where R is "red" for red, G is "green" for green, and B is "blue" for blue. Example: rgb(0, 0, 255);
rgba(red, green, blue, alpha)Creates a color based on red, green, blue and alpha values. Example: rgba(0, 0, 255, 0.3);
hsl(hue, saturation, lightness)Creates a color through the values of hue, saturation, and lightness. Example: hsl(120, 100%, 50%); // green hsl(120, 100%, 75%); // light green hsl(120, 100%, 25%); // dark green hsl(120, 60%, 70%); // soft green
hsla(hue, saturation, lightness, alpha)Creates a color through the values of hue, saturation, lightness, and alpha. Example: hsl(120, 100%, 50%, 0.3); // green with transparency hsl(120, 100%, 75%, 0.3); // light green with transparency
grayscale(color)Converts a color to grayscale, equivalent to desaturate(color, 100%). Example: grayscale(#7fffd4); Result: #c6c6c6
complement(color)Returns a complementary color, equivalent to adjust-hue($color, 180deg). Example: complement(#7fffd4); Result: #ff7faa
invert(color, weight)Returns an inverted color, with red, green, and blue values reversed, while transparency remains unchanged. Example: invert(white); Result: black
\n\n

Sass Color Getting

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
← Func Repeating Radial GradientSass Selector Func β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.

FunctionDescription & Example
red(color)Gets the red value from a color (0-255). Example: red(#7fffd4); Result: 127 red(red); Result: 255
green(color)Gets the green value from a color (0-255). Example: green(#7fffd4); Result: 255 green(blue); Result: 0
blue(color)Gets the blue value from a color (0-255). Example: blue(#7fffd4); Result: 212 blue(blue); Result: 255
hue(color)Returns the hue angle value of a color in HSL color space (0deg - 255deg). Example: hue(#7fffd4); Result: 160deg
saturation(color)Gets the saturation value of a color (0% - 100%). Example: saturation(#7fffd4); Result: 100%
lightness(color)Gets the lightness value of a color (0% - 100%). Example: lightness(#7fffd4); Result: 74.9%
alpha(color)Returns the alpha channel of color as a number between 0 and 1. Example: alpha(#7fffd4); Result: 1
opacity(color)Gets the opacity value of a color (0-1). Example: opacity(rgba(127, 255, 212, 0.5); Result: 0.5