Home Sass Color color.hue() Sass color.hue() Definition
Definition and Usage color.hue($color) returns the HSL hue of a legacy color as a number between 0deg and 360deg . Global alias: hue($color).
Official Sass docs mark it deprecated — prefer color.channel($color, "hue") on Dart Sass 1.79+. Pair with color.saturation() and color.lightness() when auditing a full HSL triple.
No longer recommended. Because color.hue() is redundant with color.channel(), migrate readers to the channel API in new code.
Official samples. color.hue(#e1d7d2) → 20deg. #f2ece4 → 34.2857142857deg. #dadbdf → 228deg.
Legacy colors only. $color must be in a legacy space (rgb, hsl, or hwb). For modern spaces, use color.channel(..., $space: hsl).
Syntax
Syntax @use "sass:color";
// Deprecated reader
color.hue(#e1d7d2); // 20deg
color.hue(#f2ece4); // 34.2857142857deg
color.hue(#dadbdf); // 228deg
// Prefer today (Dart Sass 1.79+)
color.channel(#e1d7d2, "hue");
color.channel($c, "hue", $space: hsl); Pattern: recognize color.hue in old files → rewrite with color.channel($c, "hue").
Code
SCSS Examples Examples use color.hue(). Open View Compiled CSS for verified output (matches official Sass docs samples where noted).
1. Hex 2. Docs trio 3. Wheel 4. HSL input 5. Global alias Example 1 — Warm Hex Hue (Official Docs) A soft taupe hex reports hue 20deg.
@use "sass:color";
@debug color.hue(#e1d7d2); // 20deg
.swatch {
--hue: #{color.hue(#e1d7d2)};
} .swatch {
--hue: 20deg;
} How It Works Legacy hex is mapped into HSL.Hue angle is 20deg (warm / orange-red band).Interpolation writes it into a custom property.Same read via color.channel(#e1d7d2, "hue") on 1.79+.Example 2 — Cream and Cool Grays (Official Docs) Two more official samples: a cream near orange-yellow, and a cool bluish gray.
@use "sass:color";
@debug color.hue(#f2ece4); // 34.2857142857deg
@debug color.hue(#dadbdf); // 228deg
.palette {
--cream: #{color.hue(#f2ece4)};
--cool: #{color.hue(#dadbdf)};
} .palette {
--cream: 34.2857142857deg;
--cool: 228deg;
} How It Works Even soft neutrals carry a tiny hue.Cream sits near 34deg (warm).Cool gray sits near blue at 228deg.Useful when you sort tokens by warmth.Example 3 — Primary Named Colors on the Wheel Classic CSS names land on tidy wheel positions.
@use "sass:color";
.wheel {
--red: #{color.hue(red)};
--lime: #{color.hue(lime)};
--blue: #{color.hue(blue)};
} .wheel {
--red: 0deg;
--lime: 120deg;
--blue: 240deg;
} How It Works Red is 0deg on the HSL wheel.Lime is 120deg; blue is 240deg.Landmarks make warm vs cool comparisons easier.Same idea after migrating to color.channel(..., "hue").Example 4 — Hue From an HSL Color When the input is already HSL, the hue dial matches what you wrote.
@use "sass:color";
.card {
--from-hsl: #{color.hue(hsl(200deg, 50%, 40%))};
--brand: #{color.hue(#336699)};
} .card {
--from-hsl: 200deg;
--brand: 210deg;
} How It Works hsl(200deg, …) reads back as 200deg.Brand hex #336699 lands nearby at 210deg.Both sit in the cool cyan–blue band.On 1.79+ , use color.channel for the same numbers.Example 5 — Global hue() with as * Older stylesheets sometimes import the module into the current namespace.
@use "sass:color" as *;
.panel {
--hue: #{hue(#e1d7d2)};
} How It Works as * brings members into the current scope.hue() matches color.hue().Result is still official 20deg.Prefer namespaced color.hue, then color.channel, when modernizing. Edge Cases & Pitfalls Most hue-reader bugs are writing vs reading, modern spaces, or forgetting the deg unit.
read Readers do not rotate hue color.hue only returns a number. To rotate, use color.adjust / adjust-hue with $hue.
space Legacy colors only for this helper Official docs require rgb / hsl / hwb. Prefer color.channel(..., $space: hsl) for modern spaces.
unit Result includes deg Hue is still a Sass number, but it carries the deg unit — keep that in mind for math and comparisons.
migrate Quote the channel name Write color.channel($c, "hue") with a quoted string.
Toolchain
Sass Support color.hue() remains for compatibility. New readers should use color.channel on Dart Sass 1.79+.
API Status color.hue() / hue()Deprecated reader — still works on legacy colors color.channel($c, "hue")Preferred on Dart Sass 1.79+ LibSass / Ruby Sass Global hue() may exist — no modern module path Browsers N/A — only see compiled CSS values
Compile with the Dart Sass CLI .
Remember
Key Takeaways Reads HSL hue as a number from 0deg to 360deg.
Deprecated in favor of color.channel($c, "hue").
Siblings: color.saturation() and color.lightness().
Writers use adjust / adjust-hue / complement — not this reader.
One line: use color.hue to understand old HSL reads — write new ones with color.channel.
Migrate
Migrate Notes Practical checklist:
1. Find color.hue($c) / hue($c) in legacy SCSS
2. Require Dart Sass 1.79+ for color.channel
3. Replace with color.channel($c, "hue")
4. Add $space: hsl when reading non-legacy colors
5. Use adjust / complement when you need to write hue Frequently Asked Questions What does Sass color.hue() do? color.hue($color) returns the HSL hue of a legacy color as a number between 0deg and 360deg. Example: color.hue(#e1d7d2) is 20deg; color.hue(#f2ece4) is about 34.29deg; color.hue(#dadbdf) is 228deg.
Is color.hue() deprecated? Yes. Official Sass docs list it under Deprecated Functions and say it is no longer recommended because it is redundant with color.channel($color, "hue").
What range does color.hue() return? A number from 0deg to 360deg (with the deg unit). It is still a Sass number—meta.type-of reports number.
Does color.hue() work on oklch colors? Official docs require a legacy color space (rgb, hsl, or hwb). Convert first, or use color.channel($color, "hue", $space: hsl) on Dart Sass 1.79+.
How do hue, saturation, and lightness readers relate? color.hue(), color.saturation(), and color.lightness() are sibling deprecated readers for the three HSL channels. Prefer color.channel with "hue", "saturation", or "lightness" in new code.
How do I migrate old color.hue() calls? Replace color.hue($color) with color.channel($color, "hue") after @use "sass:color" on Dart Sass 1.79+. Keep color.hue only when maintaining older compilers or legacy SCSS.
Next: Sass lighten() Deprecated helper that adds HSL lightness — prefer color.scale / adjust.
lighten() → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion