A friend of mine, Stavros Lazaris, released a CSS framework called Zeus. I installed it to see what he had built, and one idea in there led me to build an npm package before I realized the CSS spec already covered half of it.
The idea#
Zeus has a fluid engine. Every spacing and type token is a clamp() that scales between a min and a max as the container grows. The part that got me is the unit: it keys on cqi, the container query inline unit, with container-type: inline-size on body. Tokens follow the container they live in. Put the same card in a sidebar and in a main column and each one sizes itself.
The formula behind it is the one everybody uses, from Utopia to every fluid typography tutorial out there:
font-size: clamp(1rem, 0.667rem + 1.667cqi, 2rem);
Read it as: 16px at a 320px container, 32px at 1280px, a straight line between, pinned at both ends. The two odd numbers are an intercept and a slope, worked out once by a preprocessor and pasted in.
I have written that line hundreds of times, for font-size, padding, gap, border-radius. I had never once thought about where it stops working.
Where it stops working#
I wanted a button that leans a few degrees on a narrow container and straightens out on a wide one. Same formula, different unit:
rotate: clamp(-7deg, -11.667deg + 1.458cqi, 7deg);
That is a type error. cqi is a length. You cannot add a length to an angle, so the browser drops the whole declaration and the button does nothing.
The formula fails the same way for any non-length property: transition-duration in seconds, font-weight as a number, opacity, or percentages inside clip-path. Because the slope carries cqi, the expression evaluates to a length, and CSS rejects it.
The workaround we all know is a stack of media queries with hand-picked steps. Six breakpoints to walk a font-weight from 400 to 620. I have written that too.
Swap the order of operations#
The fix is a reordering. Divide first, multiply second.
Dividing one length by another gives a plain number. A bare / between two lengths only works in Chrome 140 and Safari 26, and Firefox has not shipped it, so the portable spelling is the tan(atan2(a, b)) trick from Jane Ori, which equals a / b and has worked everywhere since early 2023:
--t: clamp(0, tan(atan2(100cqi - 320px, 960px)), 1);
--t is 0 at a 320px container, 1 at 1280px, a fraction between, and it has no unit. It is progress along the range, and the browser recomputes it on every layout.
Now any property that takes calc() can use it, in its own unit:
rotate: calc(-7deg + 14deg * var(--t));
transition-duration: calc(0.06s + 1.34s * var(--t));
font-weight: calc(200 + 700 * var(--t));
letter-spacing: calc(-0.02em + 0.37em * var(--t));
clip-path: polygon(calc(24% * var(--t)) 0, 100% 0, calc(100% - 24% * var(--t)) 100%, 0 100%);
One --t for all of them. Declare it on a container and every descendant reads it. Declare it again on an inner container with its own range and everything inside follows the inner width. The cqi inside the variable resolves against whichever container the value is used in, which is exactly what you want and slightly surprising the first time.
A bonus I had not planned: descending ranges work. calc(26rem - 24rem * var(--t)) shrinks. The classic form cannot do that, because clamp(26rem, ..., 2rem) returns 26rem forever when min is bigger than max. My own first helper had that bug, and I only caught it because I measured the computed width and got 26rem at every size. There is a bar on the demo page that shows the stuck version next to the working one.
Wrapping it in Sass#
I got tired of doing subtraction in my head, so I wrote a few functions:
@use "cq-lerp" as *;
.card {
@include cq-track(240, 560);
padding: fluid-on(0.6rem, 1.4rem);
border-radius: fluid-on(0.4rem, 1rem);
rotate: fluid-on(-7deg, 7deg, var(--cq-te));
font-weight: fluid-on(400, 620, var(--cq-t), "");
}
cq-track declares two variables: --cq-t (linear) and --cq-te (run through a smoothstep, for things that should settle in gently). fluid-on takes a min and a max in whatever unit, works out the difference and the sign, and writes the calc(). fluid() is the standalone version for when you want one value with its own range baked in.
Then I built six buttons to test different unit families: padding and sizing lengths, rotation and skew angles, a variable font-weight from 200 to 900, percentages for border-radius and saturation, transition durations in seconds, and a polygon clip-path.

Then a whole app shell, twice. One stylesheet uses this. The other is what we all shipped until this year: clamp() with vw for every length, media queries for the font weight, and one fixed transition duration, because nobody writes six breakpoints for a duration. A switch flips between them in place.
Live, resizable, no JavaScript: subamanis.github.io/cq-lerp
At this point it covered every unit I needed without width breakpoints or keyframes. Layout changes (stacking, hiding, reordering) still need container or media queries, of course, but the continuous scaling part was handled by one function.
Then I read the spec#
Before publishing, I checked whether someone had already done this. It turns out the CSS Working Group had:
--t: progress(100cqi, 320px, 1280px);
CSS Values 5. It returns where the first argument sits between the other two, as a number from 0 to 1, clamped. It is my --t line with the subtraction and division moved into the browser. Chrome 138, Safari 26, Firefox 155.
I had reinvented progress(), complete with a Sass wrapper.
While I was at it I found sass-lerp, which has done calc-based interpolation in Sass for years, and posts from MadeByMike and Typetura circling the same ground. The one piece I could still call mine was putting the halves together around a container unit and seeing that it opens every unit at once.
Why it still needs a package#
There are two reasons the package is still useful: browser support and the interpolation math itself.
The first is support. Those version numbers mean browsers from 2026 onward. Everything older gets nothing from progress(). The tan(atan2()) fallback reaches back to early 2023 (Chrome 111, Safari 16, Firefox 110). So the package declares the fallback and upgrades in place:
--cq-t: clamp(0, tan(atan2(100cqi - 320px, 960px)), 1);
@supports (opacity: progress(1px, 0px, 2px)) {
--cq-t: progress(100cqi, 320px, 1280px);
}
One catch with that feature test: my first version was @supports (width: progress(...)), which is always false, because progress() returns a number and width rejects numbers. The upgrade never fired once and I did not notice until I measured. Test on opacity.
The second reason is that progress() hands you a 0 to 1 and stops there. The calc(min + (max - min) * t) is still yours to write, in the right unit, with the right sign. The Sass functions do that part, catch a rem mixed with a px, and turn a bare 0 into 0deg when the other end is an angle.
The part progress() cannot reach#
progress() interpolates over whatever you give it. Give it 100vw and you have the viewport, same as the clamp()-and-vw genre. Give it 100cqi inside a container and the thing being measured changes.

That sidebar has a drag handle. The window never moves. Under cq-lerp the padding, the type size, the letter spacing and the weight of the links all follow the width of the sidebar itself. Under the conventional stylesheet nothing moves, because every viewport-based technique is reading a number that did not change.
Same story with the three cards on the demo page: identical markup in a 240px, a 380px and a 520px slot, on one screen, at the same time. Each card sizes itself by its slot. A media query has nothing to key off, since all three see the same viewport.
That is what stays useful no matter how far progress() support spreads, and it is why the package has cq in its name.
Links#
- Demo: subamanis.github.io/cq-lerp
- Source: github.com/subamanis/cq-lerp
- Package:
npm i cq-lerp, with a plain CSS entry atcq-lerp/cssif you do not use Sass - Zeus, where the container-based fluid engine idea comes from: zeuscss.com