CSS Clamp Generator

Generate CSS clamp() values for fluid typography and spacing — responsive sizes without media queries.

Viewport Range

Value Range

Generated CSS
Sample Text
Computed value:
Common Presets

About CSS clamp()

The CSS clamp() function takes three values: a minimum, a preferred (fluid) value, and a maximum. It clamps the preferred value between the min and max bounds. For fluid typography: clamp(1rem, 2.5vw + 0.5rem, 3rem) means the font size is at least 1rem, at most 3rem, and scales smoothly between those bounds relative to the viewport width — no media queries needed.

The preferred value is a linear interpolation between your min and max values across your viewport range. The formula: slope = (maxVal - minVal) / (maxVp - minVp) and intercept = minVal - slope * minVp. This generates a calc() expression for the fluid middle value that, combined with clamp, creates perfectly smooth responsive scaling.

FAQ

Why is clamp() better than media queries for typography?
Media queries create abrupt jumps at breakpoints. clamp() creates perfectly smooth, continuous scaling. Your text is the right size at every viewport width, not just at the breakpoints you remembered to write. Fewer lines of CSS, better result.
Can I use clamp() for things other than font-size?
Yes! clamp() works for any numeric CSS property: padding, margin, gap, width, height, border-radius. It is especially useful for spacing in design systems where you want values to scale proportionally with the viewport rather than jumping at fixed breakpoints.