v139 · css
CSS Custom Functions
Custom Functions are similar to custom properties, but instead of returning a single, fixed value, they return values based on other custom properties, parameters, and conditionals.
concepts
-
Function Cookbook
Author-defined CSS functions. Declare with @function, call like any built-in. Parameters get defaults, results flow into any property that accepts the return type.
-
Typed Parameters
Parameters declare
<color>,<length>,<percentage>. Invalid input is rejected per spec and the function falls back. Try passing the wrong type and watch it gracefully fail. -
Functional Design Tokens
Retire the
--space-1 / --space-2 / --space-3ladder for a single@function --space(--step). Sliders dial padding, type tier, and radius scale across four cards at once. Swap the scale in one place. -
Easing Library
A single
@function --ease(--name)that maps named easing tokens tocubic-bezier()values. Every component calls--ease(spring)or--ease(back-out)— the curve is centralised and swappable. -
Color Tools
Lighten, darken, saturate, alpha, and mix as CSS functions:
--lighten(var(--brand), 15%)wrapsoklch(from …)relative color syntax. Static palettes plus a live color picker that recalculates instantly in CSS — no preprocessor, no JS. -
Responsive Grid System
A full grid toolkit from
@function: column-width calculation (--col-width()), fluid type scaling (--fluid-size(min, max, at-min, at-max)), and spacing scale generation. Live grid editor adjusts column count and gap density; column-width bar chart shows span calculations.
why it shipped
Custom Functions are similar to custom properties, but instead of returning a single, fixed value, they return values based on other custom properties, parameters, and conditionals.