What is CSS clamp()?
The CSS clamp() function picks a value between a minimum and a maximum, with a preferred value in the middle. For type it lets a size grow smoothly as the screen gets wider, then stop at a limit. You get fluid text without writing media queries.
A common form is clamp(1rem, 0.6667rem + 1.6667vw, 2rem). That means: never smaller than 1rem, never larger than 2rem, and in between grow by 1.6667% of the viewport width plus a fixed part. This tool works out that middle part from the sizes and screen widths you choose, and also shows a table of the size at common widths.
slope = (max − min) ÷ (maxViewport − minViewport); intercept = min − slope × minViewport; value = clamp(min, intercept + slope × 100vw, max).
How to use the CSS clamp() Calculator
- Enter the smallest and largest size.
- Enter the screen widths where growth starts and stops.
- Choose rem or px output.
- Copy the clamp() value into your CSS.