CKTIS / CSS
progress() — normalized progress between values
`progress()` computes where a value lies between a start and end as a unitless number.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
progress( no-clamp? <calc-sum>, <calc-sum>, <calc-sum> )progress() computes where a value lies between a start and end as a unitless number.
progress(50px, 0px, 100px) produces used size 70px; progress(150px, 0px, 100px) clamps and produces 120px. Form progress(no-clamp 150px, 0px, 100px) reports support false in this Chromium, so the declaration computes to automatic 200px; inconsistent progress(1px, 0deg, 100px) also returns false.
Grammar: progress( no-clamp? <calc-sum>, <calc-sum>, <calc-sum> ).
The calculation is (value - start) / (end - start). Without no-clamp, the result clamps from 0 to 1; the unclamped form can leave that range but needs feature detection here. All three arguments require a consistent type: numbers, percentages, or compatible dimensions. If start equals end, the clamped form returns zero, while the unclamped form can yield zero or signed infinity. CSS Values 5 remains in early exploration.
Examples
const host=document.createElement('div');host.style.width='200px';document.body.append(host);
const used=value=>{const box=document.createElement('div');box.style.width=value;host.append(box);return getComputedStyle(box).width};
const midpoint=used('calc(20px + 100px * progress(50px, 0px, 100px))');
const clamped=used('calc(20px + 100px * progress(150px, 0px, 100px))');
const extended=used('calc(20px + 100px * progress(no-clamp 150px, 0px, 100px))');
const noClampSupported=CSS.supports('width','calc(20px + 100px * progress(no-clamp 150px, 0px, 100px))');
const mixed=CSS.supports('width','calc(100px * progress(1px, 0deg, 100px))');
console.log('midpoint='+midpoint+'; clamped='+clamped+'; no-clamp-supported='+noClampSupported+'; no-clamp-result='+extended+'; mixed-types='+mixed);Result
midpoint=70px; clamped=120px; no-clamp-supported=false; no-clamp-result=200px; mixed-types=false
`progress()` computes where a value lies between a start and end as a unitless number.