CSS Clamp Generator

Generate fluid responsive CSS clamp() values for font sizes with live preview.

Fluid typographyrem + vwBatch scale output

① Set min/max font sizes and viewports ② Click Generate ③ Copy the clamp() CSS value

What is CSS clamp() for fluid typography?

The CSS clamp(min, preferred, max) function enables truly fluid typography that scales smoothly between any two viewport widths without breakpoints. The preferred value combines a viewport-relative unit (vw) and a rem offset, calculated so the font size exactly equals the minimum at the minimum viewport and the maximum at the maximum viewport. This technique — popularized by Mike Riethmuller and later formalized by tools like Utopia — produces a single CSS declaration that replaces multiple @media query overrides. The slope (vw coefficient) controls how fast the font grows with the viewport, while the intercept (rem offset) anchors the baseline. Using rem units ensures the scale respects the user's browser font size preferences, which is critical for WCAG 1.4.4 compliance.

Frequently asked questions

CSS clamp(min, preferred, max) takes three arguments. The min value is the smallest the property can be, the preferred value is the ideal (usually a vw + rem expression), and the max is the upper bound. The browser always keeps the result between min and max, regardless of the preferred calculation.
The slope is (maxSize - minSize) / (maxViewport - minViewport). Multiplied by 100, this gives the vw coefficient. The rem intercept is (minSize - slope × minViewport) / rootSize. The final clamp is: clamp(minRem, slopeVw + interceptRem, maxRem). This ensures the font size is exactly minSize at minViewport and maxSize at maxViewport.
Media queries produce abrupt jumps at defined breakpoints — the font size snaps from one value to another. clamp() produces a smooth linear interpolation between two sizes across the entire viewport range. No breakpoints are needed, the code is shorter, and the result is more polished visually.
For vanilla CSS, declare the values as custom properties in :root (e.g., --text-lg: clamp(1.125rem, 1.5vw + 0.75rem, 2rem)) and use them throughout your stylesheets. For Tailwind v3, add them to theme.extend.fontSize in tailwind.config.js. For Tailwind v4, use @theme in your CSS file with the custom properties directly.
CSS clamp() has been supported in all major browsers since 2020 (Chrome 79, Firefox 75, Safari 13.1, Edge 79). Global support is over 97%. For the rare legacy browsers that lack support, the tool also generates a px-only fallback (using the min value or a midpoint) that you can place before the clamp() declaration.
clamp() works for any length property that benefits from fluid scaling. For typography, it eliminates the need for font-size @media overrides. For spacing (padding, margin, gap), it creates layouts that breathe proportionally. However, avoid using clamp() where abrupt control is required — for example, navigation breakpoints or grid column counts are better served by @media queries.
Common issues: (1) Wrong root font size — if the user or a parent sets a different rem base, the rem intercept will be off; use the actual root size in the calculator. (2) Mixed units — combining px and rem in the preferred value without conversion. (3) Min greater than max — the clamp collapses to the min value. (4) Very large vw coefficient — the font grows too fast on mid-sized viewports. Always test with the viewport simulator before shipping.

Explore Our Network