color.complement() returns the complement of a color by rotating its hue 180deg in a polar color space. Load it with @use "sass:color". The global alias is complement().
$space must be polar: hsl, hwb, lch, or oklch (Dart Sass 1.79+). The result always stays in the original color’s space. For legacy hex/RGB colors without $space, Sass defaults to hsl — still pass $space explicitly when you can.
Official idea.
color.complement(#6b717f) → #7f796b (HSL hue 222deg → 42deg). In oklch the same hex lands on a different RGB result.
Round-trip.
Complement twice in the same space and you return to the starting hue: color.complement(color.complement($c)).
Polar spaces only.
$space cannot be rgb or lab. Those have no hue dial to flip.
Hue +180deg in a polar space — that is the whole idea.
Load@use "sass:color" and prefer the module name.
Pass $space explicitly on Dart Sass 1.79+.
Twice restores the original hue in the same space.
One line:color.complement is the clearest way to ask Sass for the opposite hue.
Compile
Compile Notes
Conceptual flow:
flow.txt
1. @use "sass:color"
2. Resolve $color (and optional polar $space)
3. Rotate hue by 180deg
4. Return a new color in the original space
5. Emit a finished CSS color — no complement() left
Frequently Asked Questions
color.complement($color, $space: null) rotates the color’s hue by 180deg in a polar color space and returns the complementary color. Example: color.complement(#6b717f) is #7f796b.
Add @use "sass:color"; then call color.complement($brand). Prefer the module form in new SCSS. The global alias is complement().
Official docs require a polar space: hsl, hwb, lch, or oklch. The $space argument needs Dart Sass 1.79+. For legacy hex/RGB colors without $space, Sass defaults to hsl.
Yes for the same space. Rotating hue by 180deg twice returns you to the starting hue, so color.complement(color.complement($c)) matches $c for typical opaque colors.
complement is a convenience for a full opposite hue. You can also write color.adjust($c, $hue: 180deg) in HSL for a similar idea, but complement is clearer when you want the opposite color.
The module form needs Dart Sass with @use (about 1.23+). The $space parameter needs Dart Sass 1.79+. LibSass/Ruby Sass may expose a global complement() but lack the modern module API.