Sass color.mix()

Beginner
12 min read
Updated: Nov 2026
5 examples
Compiled CSS

Definition and Usage

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

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+).

Weight / Method / CSS

How the knobs fit together:

NeedUse
Even blend (legacy)color.mix($a, $b) — weight 50%
More of first colorcolor.mix($a, $b, 80%)
CSS color-mix math (1.79+)color.mix($a, $b, $method: rgb) / oklch
Runtime browser blendCSS color-mix(in srgb, …)
Relative channel change (one color)color.scale()
WeightFeel
0%All $color2
50% (default)Even blend
100%All $color1

SCSS Examples

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).

SCSS
@use "sass:color";

@debug color.mix(#036, #d2e1dd); // #698aa2

.swatches {
  color: color.mix(#036, #d2e1dd);
  background: color.mix(#036, white, 15%);
}

How It Works

  1. No weight means 50% of each color.
  2. Midtone compiles to #698aa2.
  3. 15% brand + white keeps a soft wash related to #036.
  4. Browsers receive hex — no Sass call remains.

Example 2 — Weight Ladder for Hover States

Push toward the brand or toward the tint for interactive steps.

SCSS
@use "sass:color";

$brand: #036;
$tint: #d2e1dd;

.palette {
  --mid: #{color.mix($brand, $tint)};
  --more-brand: #{color.mix($brand, $tint, 80%)};
  --more-tint: #{color.mix($brand, $tint, 20%)};
}

.button:hover {
  background: color.mix($brand, $tint, 65%);
}

How It Works

  1. 80% stays close to the brand.
  2. 20% drifts toward the mint tint.
  3. Hover at 65% is a practical mid-dark step.
  4. No hand-picked hexes for each interactive state.

Example 3 — Historical Mix Respects Opacity

Without $method, relative opacity also shapes the blend.

SCSS
@use "sass:color";

.overlay {
  // Half-opaque cream mixed with solid slate
  background: color.mix(rgba(242, 236, 228, 0.5), #6b717f);
}

How It Works

  1. Historical algorithm factors in each color’s opacity.
  2. Cream is 50% opaque, so the result stays translucent.
  3. Not a fully opaque midtone.
  4. With $method, missing channels take the other color’s value (CSS rules).

Example 4 — $method: RGB vs Oklch (Dart Sass 1.79+)

Same two hexes, different interpolation spaces (official docs samples).

SCSS
@use "sass:color";

// Requires Dart Sass 1.79+
@debug color.mix(#036, #d2e1dd, $method: rgb);   // #698aa2
@debug color.mix(#036, #d2e1dd, $method: oklch); // modern midtone

.methods {
  --rgb: #{color.mix(#036, #d2e1dd, $method: rgb)};
  --oklch: #{color.mix(#036, #d2e1dd, $method: oklch)};
}

.polar {
  // Hue interpolation method on a polar space
  color: color.mix(
    oklch(80% 20% 0deg),
    oklch(50% 10% 120deg),
    $method: oklch longer hue
  );
}

How It Works

  1. RGB method lands on familiar #698aa2.
  2. Oklch method follows perceptual CSS color-mix math.
  3. longer hue takes the long way around the hue circle.
  4. Result space follows $color1.

Example 5 — Sass Mix vs CSS color-mix() + Global Alias

Compile-time tokens next to a runtime CSS mix; module and global names match.

SCSS
@use "sass:color";

.chip {
  // Sass: finished color in the CSS file
  color: color.mix(#036, #d2e1dd);
  --module: #{color.mix(#036, #d2e1dd)};
  --global: #{mix(#036, #d2e1dd)};
}

.chip.is-live {
  // CSS: browser blends at paint time (not a Sass helper)
  background: color-mix(in srgb, #036 50%, #d2e1dd);
}

How It Works

  1. Module and global Sass mixes compile to the same hex.
  2. Prefer color.mix() so it never looks like CSS color-mix().
  3. CSS color-mix() stays for runtime / theme-driven blends.
  4. Use Sass when the blend must be fixed in the stylesheet.

Edge Cases & Pitfalls

Most mix bugs are confusing Sass with CSS color-mix, skipping $method on modern colors, or assuming every space yields the same midtone.

method

Non-legacy colors need $method

oklch / lab / color() inputs require an explicit interpolation method on Dart Sass 1.79+.

space

RGB ≠ oklch midtones

Same weight, different $method can produce different blends. Pick the space on purpose.

css

Sass vs CSS color-mix()

Sass finishes at compile time. CSS blends in the browser. Prefer module color.mix() naming.

weight

Weight is toward $color1

80% means more of the first argument — swap the order if the bias feels inverted.

Sass Support

This is about Sass compilers, not browsers. Compiled CSS receives a finished color (unless you intentionally emit CSS color-mix()).

FeatureStatus
@use "sass:color" / color.mixDart Sass 1.23+
$weight (0%–100%)Widely available
$method (CSS algorithm)Dart Sass 1.79+
Global mix()Older compilers / legacy SCSS
LibSass / Ruby SassNo modern module / $method API

Compile with the Dart Sass CLI.

Key Takeaways

  • 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 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.

Next: Sass color.same()

Check whether two colors represent the same color across spaces.

color.same() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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