tools.junyo.dev

CSS Clamp Calculator

Generate fluid responsive values with clamp() — typography and spacing that scale smoothly.

More about CSS clamp
Why clamp() changed how we do responsive typography

Before clamp(), responsive typography meant a media query for every breakpoint. With clamp(), scaling happens continuously between two screen sizes.

The CSS `clamp(min, preferred-value, max)` is a mathematical function that constrains a value between a minimum and a maximum. For fluid typography, the preferred value is a combination of `vw` (viewport width) with a fixed `rem` offset, geometrically derived from the target font sizes and viewport widths. The slope formula is simple: `(maxPx - minPx) / (maxVp - minVp)`. The intercept positions the line at the origin. The result is text that scales pixel-by-pixel between viewports with no jumps at all.

How to use

Set the extremes and let the math work.

  1. Define the minimum and maximum size (in px or rem) and the bounding viewports where each size applies.
  2. Review the detailed calculation with slope and intercept, then check the three-scale preview.
  3. Copy the CSS and paste it into your token file or global CSS variable.
References

Sources and references for this tool

These references help contextualize formulas, standards, APIs and limitations used on this page. They do not replace professional validation when a result has legal, financial, medical or operational impact.

FAQ

Frequently asked questions

It's a CSS function that constrains a value between a minimum and a maximum. In the middle it accepts any CSS expression — typically `viewport-width + rem-constant` for fluid typography.

Design