Both functions derive colours from other colours in CSS, so one --brand token can produce hover, border and tint variants that follow it, even when it changes at runtime. Preprocessors can't do that because they run before var() exists.
color-mix() (CSS Color 5) interpolates between colours:
color-mix(in oklch, var(--brand) 70%, white)
- The space decides the result. Blue and yellow mixed
in srgbgave exact grey;in oklchgave a vivid teal. Withoutin …the default is Oklab, a good general choice. - Percentages. One missing percentage is
100%minus the other; both missing is 50/50. If they sum to more than 100% they're scaled down. If they sum to less, the mix is made at full strength and its alpha is multiplied by the sum:red 20%, blue 20%is a 50/50 purple at alpha 0.4. - Polar spaces (
hsl,oklch,lch) interpolate hue along the shorter arc unless you writelonger hue,increasing hueordecreasing hue.
Relative colour syntax (also Color 5) starts any modern colour function with from <color>:
oklch(from var(--brand) calc(l - 0.1) c h) /* darker */
oklch(from var(--brand) l c calc(h + 180)) /* complement */
rgb(from var(--brand) r g b / 50%) /* translucent */
The origin is converted into that function's space, and each channel keyword (l, c, h, r, alpha…) becomes a plain number: r is 0–255 in rgb(), l is 0–1 in oklch(). Any channel can be a keyword, a literal or a calc().
Choose color-mix() to blend towards another colour (tints, overlays) and relative syntax to adjust one channel precisely (lightness steps, alpha). Both are resolved when the value computes, so getComputedStyle returns the final colour; a currentColor inside color-mix() stays unresolved so each element mixes with its own color.