color.same($color1, $color2) returns a boolean: true when the two colors visually render as the same color. Unlike ==, space differences do not matter when the values match in the xyz color space. Load it with @use "sass:color" on Dart Sass 1.79+. There is no separate global alias.
Official docs also note that missing channels are treated as equivalent to zero.
Examples target Dart Sass 1.79+. Booleans are interpolated into custom properties so you can open View Compiled CSS. @debug lines print to the compiler terminal / log.
Module only on Dart Sass 1.79+ — no global same().
One line: use color.same when you care whether two tokens look the same — not whether they were written in the same space.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Require Dart Sass 1.79+
2. @use "sass:color"
3. Prefer color.same($a, $b) over == for cross-space look
4. Remember missing channels count as zero
5. Pair with color.to-space() when migrating spaces
Frequently Asked Questions
color.same($color1, $color2) returns true if the two colors visually render as the same color. Example: color.same(#036, #036) is true; color.same(#036, #037) is false.
The == operator compares Sass color values more strictly by representation. color.same() treats colors as equal when they match in the xyz color space—even if one is hex and the other is oklch.
Official docs: missing channels are treated as equivalent to zero. That is why color.same(hsl(none 50% 50%), hsl(0deg 50% 50%)) is true.
Use it when comparing tokens that may live in different spaces after color.to-space(), or when none / missing channels should count as zero for visual equality.
No. Use the module form color.same() after @use "sass:color".