Patch Bandit

The story / The lab

Gummy bear · 2026-11-22

CSS color-mix() playground

CSS color-mix() blends two colors right inside your stylesheet, so you can build hover states, soft tints, and dark shades from one brand color without hand-picking hex codes. Pick two colors and slide the mix ratio below to compare four color spaces at once.

One base color in, a whole palette out, straight from the browser.

Snick the raccoon celebrating a fresh color blend

Pick two colors and a ratio

Change either swatch or drag the slider. The browser computes every live blend on the right using native CSS color-mix().

color-mix(in oklch, #86e3be 50%, #7a55b0)

in oklch · bright middle

in oklab · smooth blend

in srgb · classic RGB

in hsl · wheel sweep

5-step blend in oklch (90% to 10% Color A)

Same 5 steps in srgb (watch the middle)

Why color spaces give different mixes

The same two colors at 50% can look crisp in one space and muddy in another. Pick the space that matches the job.

  • in oklch

    Bright, even hover states

    Keeps lightness steady as hue shifts, so mixing opposite colors stays vivid instead of sinking into grey. Great default for buttons and accents.

  • in oklab

    Clean tints and shades

    Blends straight across perceptual lightness without swinging around the color wheel. Ideal when mixing a brand color with white or dark ink.

  • in srgb

    Classic channel average

    Averages red, green, and blue values directly. Familiar from older tools, though opposite hues often dip dark and muted near 50%.

  • in hsl

    Rainbow transitions

    Walks around the hue wheel between Color A and Color B, which can jump through extra hues on the way from mint to violet.

Copy the CSS color-mix() recipes

Tints, shades, and alpha rings (CSS)
:root {
  --brand: #86e3be;
}

/* Lighter tint (mix with white) and deeper shade (mix with dark ink) */
.btn-soft  { background: color-mix(in oklch, var(--brand) 25%, #ffffff); }
.btn-hover { background: color-mix(in oklch, var(--brand) 82%, #140a22); }

/* Soft see-through ring without splitting hex into RGB numbers */
.card-ring { border-color: color-mix(in oklch, var(--brand) 35%, transparent); }

Color spaces with a fallback (CSS)
/* Safe fallback first, then color-mix() in your chosen space */
.swatch {
  background: #809cc7;
  background: color-mix(in oklch, #86e3be 50%, #7a55b0);
}

/* Try different spaces for different blends:
   in oklch — stays bright and lively through the middle
   in oklab — smooth perceptual blend without hue swings
   in srgb  — classic RGB channel average (can look grey in the middle)
   in hsl   — travels around the color wheel */

Browser support: CSS color-mix() is Baseline Widely Available across current Chrome, Edge, Safari, and Firefox (supported across major browsers since 2023). List a plain hex color one line above it if you need a fallback for much older browsers. Tested in Chromium only.

The fine print, in plain words

Why this is free

We're raccoons who think simple things shouldn't cost a monthly fee. We take techniques apart, explain them in plain words, and give them away. The code on this page is MIT licensed: copy it, change it, and share it.

This is one of twelve experiments so far. Our first browser tool (Bandit Codes) is live now, and the rest sit as ideas in the stash.