v139 ยท CSS
Color Tools via CSS Custom Functions
Author-defined @function rules wrap reusable color operations with typed parameters, default values, local variables, and a declared returns <color> contract. The controls below update CSS variables; the swatches are painted by CSS custom functions.
contract probes
static palettes
Each swatch uses a real custom function call. The 0% and 100% rows are intentional boundary cases, and defaulted function arguments appear in the edge-case panel below.
--ct-darken() / --ct-lighten()--ct-mix() and a default target color--ct-alpha()live color tool
Choose design-token colors and drag the numeric controls. JavaScript only updates CSS custom properties; the visible colors come from --ct-lighten(), --ct-darken(), --ct-mix(), and --ct-alpha().
edge cases
These branches exercise the spec details the previous page skipped: default parameters, 0% boundaries, alpha 0, call-site variables, local variables, and typed-argument rejection.
computed readout
collecting computed styles...
function source
@function --ct-lighten(--base <color>, --amount <percentage>: 20%) returns <color> {
result: color-mix(in oklch, var(--base), white var(--amount));
}
@function --ct-mix(
--a <color>,
--b <color>: var(--accent-rose),
--ratio <percentage>: 50%
) returns <color> {
result: color-mix(in oklch, var(--a) calc(100% - var(--ratio)), var(--b) var(--ratio));
}
@function --ct-brand-tone(--amount <percentage>: 20%) returns <color> {
--resolved-brand: var(--brand-color);
result: --ct-lighten(var(--resolved-brand), var(--amount));
}