color.channel() returns the value of one channel as a number. Load it with @use "sass:color". It needs Dart Sass 1.79+.
The channel name must be a quoted string ("hue", "red", "alpha", …). Optional $space is an unquoted color-space name (rgb, hsl, oklch, …) and defaults to the color’s own space.
Official idea.
color.channel(hsl(80deg 30% 50%), "hue") → 80deg. With $space: rgb, the same color’s red is 140.25.
Units.
Hue returns deg. Saturation, lightness, whiteness, and blackness return %. RGB and alpha are usually unitless.
Missing channels return 0.
Official docs: a missing channel yields 0 (with a unit when needed). Use color.is-missing() to detect that case explicitly.
Replace deprecated color.red / blue / alpha readers in new code.
One line:color.channel is the modern way to read any single color dial as a number.
Compile
Compile Notes
Conceptual flow:
flow.txt
1. @use "sass:color"
2. Resolve $color (and optional $space)
3. Look up the quoted $channel
4. Return a number (deg / % / unitless)
5. Use that number in if(), rgba(), or CSS vars — then emit CSS
Frequently Asked Questions
color.channel($color, $channel, $space: null) returns the numeric value of one channel. Example: color.channel(hsl(80deg 30% 50%), "hue") is 80deg.
Pass a quoted string such as "red", "hue", "lightness", or "alpha". Unquoted names are not correct for $channel.
color.channel() and its $space argument need Dart Sass 1.79+. On older Dart Sass, use space-specific getters like color.red(), color.hue(), or color.lightness().
Hue in hsl/hwb/lch/oklch returns deg. Saturation, lightness, whiteness, and blackness return %. Other channels (including RGB and alpha) are usually unitless.
Official docs say channel() returns 0 (with an appropriate unit when needed). Use color.is-missing() when you need to detect missing channels explicitly.
channel reads a number. adjust and change return a new color by shifting or replacing channels.