color.mix() returns a color that is a mixture of $color1 and $color2. A larger $weight (default 50%) keeps more of $color1. Load it with @use "sass:color". The global alias is mix().
On Dart Sass 1.79+, optional $method is a color-space name (and for polar spaces you may add a hue method like longer hue). With $method, Sass uses the same algorithm as CSS color-mix() and returns a color in $color1’s space.
Historical vs modern.
If both colors are legacy and $method is omitted, Sass keeps its older opacity-aware mix. Non-legacy colors require$method.
Official samples.
color.mix(#036, #d2e1dd, $method: rgb) → #698aa2. Same pair with $method: oklch yields a different midtone. Polar: $method: oklch longer hue can land at oklch(65% 0.06 240deg).
Not CSS color-mix().
Sass compiles a finished color. CSS color-mix() blends at paint time in the browser.
Syntax
Syntax
SCSS
@use "sass:color";
color.mix(#036, #d2e1dd); // #698aa2 (legacy / historical)
color.mix(#036, #d2e1dd, 75%); // more of #036
color.mix(#036, #d2e1dd, $method: rgb); // CSS algorithm in rgb
color.mix(#036, #d2e1dd, $method: oklch); // perceptual midtone
color.mix($a, $b, $method: oklch longer hue); // polar + hue path
// Global alias
mix(#036, #d2e1dd);
Pattern: pick two brand colors → bias with $weight → pass $method when the interpolation space matters (1.79+).
Examples 1–3 and 5 compile on everyday Dart Sass. Example 4 shows official $method results for Dart Sass 1.79+. Open View Compiled CSS to see what Dart Sass emits.
Example 1 — Even Blend of Two Brand Colors
Default 50% mix (classic docs pair: deep blue + mint).
Blend two colors — larger $weight keeps more of $color1.
$method (1.79+) uses CSS color-mix math; required for non-legacy colors.
Legacy without method keeps the historical opacity-aware algorithm.
Prefer color.mix() over looking like CSS color-mix().
One line:color.mix builds compile-time blends — tune with weight, choose a method on 1.79+.
Compile
Compile Notes
Conceptual flow:
flow.txt
1. @use "sass:color"
2. Resolve $color1, $color2, and $weight
3. If $method set → CSS color-mix algorithm (1.79+)
4. Else (legacy only) → historical opacity-aware mix
5. Emit a finished CSS color in $color1’s space (with method)
Frequently Asked Questions
color.mix($color1, $color2, $weight: 50%, $method: null) returns a color that is a mixture of the two inputs. Example: color.mix(#036, #d2e1dd) is #698aa2.
Weight must be between 0% and 100%. A larger weight uses more of $color1; a smaller weight uses more of $color2. Default is 50% (an even blend).
On Dart Sass 1.79+, $method is a color space name (optionally with a hue interpolation method for hsl, hwb, lch, or oklch). Sass then mixes with the same algorithm as CSS color-mix(). Example: color.mix(#036, #d2e1dd, $method: oklch).
Same idea, different stage. Sass color.mix() runs at compile time and writes a finished color into CSS. CSS color-mix() runs in the browser. Prefer Sass when the blend must be fixed in the stylesheet.
Add @use "sass:color"; then call color.mix($a, $b) or color.mix($a, $b, 75%). Prefer the module form. The global alias is mix().
The module form needs Dart Sass with @use (about 1.23+). The $method argument needs Dart Sass 1.79+. LibSass/Ruby Sass may expose a global mix() but lack the modern module and $method API.