Tool 002 / Fluid CSS

Responsive values.
Calculated, not guessed.

A CSS clamp calculator for fluid typography, spacing and layout values. Set your size limits, choose the viewport range, preview the result and copy the CSS you actually need.

Live calculationpx or rem outputCopy-ready CSS
A single fluid rule
clamp(min,
  preferred,
  max)

Keep the result within bounds while a viewport-relative value scales in between. The generator calculates the intercept and vw slope from your endpoints.

MINIMUMFLUID RANGEMAXIMUM
Fluid value / live calculator

Give it the limits.
Take the guesswork out.

Change the size endpoints, viewport boundaries or output unit. The CSS and preview update locally as you adjust the values.

Generator settings

INPUT / 01

Calculation updates as you type.

Generated CSS

OUTPUT / 02
CSS declarationfont-size: clamp(1rem, calc(0.3333rem + 2.963vw), 3rem);
768px

Make space for ideas.

Fluid values move with the viewport, then stop at the bounds you defined. One rule; fewer breakpoint overrides.

clamp() / live preview
Calculated value at preview width1.7556rem at 768px
Tailwind-style arbitrary value
fontSize:[clamp(1rem,calc(0.3333rem+2.963vw),3rem)]

The snippet is a starting point. Confirm the syntax against your Tailwind version and the property you are styling.

What does clamp() do?clamp(minimum, preferred, maximum) uses the preferred value while it sits between the bounds, but never resolves below the minimum or above the maximum. The preferred expression can be a fixed value, a viewport calculation or another valid CSS expression.

How a CSS clamp calculator works

To create a linear fluid value, the generator finds the slope between two desired size/viewport points. It then calculates the intercept so the preferred expression equals the minimum size at the minimum viewport. The bounds protect the value outside the range.

THE CALCULATION / CONCEPTLINEAR SCALE
change in size (px)
÷ change in viewport width (px)
× 100 = vw coefficient

intercept (px)
= minimum size (px)
− (vw coefficient ÷ 100 × minimum viewport)

clamp(minimum, calc(intercept + coefficient × 1vw), maximum)

For a 1rem minimum and 3rem maximum over 360px to 1440px, with a 16px root size, the calculated preferred value is approximately calc(0.3333rem + 2.963vw). The full expression is clamp(1rem, calc(0.3333rem + 2.963vw), 3rem). At the endpoints, the preferred expression meets the requested size; outside the range, the minimum or maximum takes over.

Should the generator output rem or px?

For fluid typography, rem is a strong default because it relates to the root font size and can preserve scaling when users change their browser settings. Pixel-based values can be appropriate in some layout contexts, but don’t assume a fixed unit is accessible simply because its numerical value looks correct on your own screen.

CSS `clamp()` has broad modern-browser support. Still test your results with keyboard navigation, zoom, text enlargement and the real content that will use the rule. A mathematically smooth scale can still be a poor design decision if the minimum is too small or the maximum creates an awkward line length.

Where can you use a fluid value?

Use clamp for any property that accepts an appropriate length, such as font size, padding, margin, gap, width and border radius. Choose the property before you copy the output: a value designed for a type scale may not make sense as a width or spacing token.

When not to use clamp()

Clamp changes a value continuously between bounds. It doesn't choose a new layout structure. If a navigation bar needs to turn into a menu, a multi-column layout needs to stack, or component behavior changes at a breakpoint, media queries or container queries remain useful. A fluid value and a breakpoint-driven layout can work together.

For worked typography scales and accessibility notes, read the fluid typography guide. For a property-by-property collection, use the CSS clamp examples.

FAQ / CSS clamp

Questions about fluid values.

Use the calculator as a tool, not a substitute for testing.

What does a CSS clamp generator do?

A CSS clamp generator calculates a value that grows between a minimum and maximum size over a chosen viewport range, then produces a CSS clamp(minimum, preferred, maximum) expression.

How is the preferred clamp value calculated?

The tool calculates a linear slope from the difference between the size endpoints and the viewport endpoints, then calculates an intercept that meets the minimum at the smaller viewport. The preferred expression combines that intercept with a viewport-relative vw term.

Should I use rem or px in clamp()?

For text and scalable spacing, rem bounds and an rem intercept can better respect the user’s root font size. Pixel output can still be useful for some fixed design-system values; test your choice with browser zoom and user font-size settings.

Can I use clamp() for padding, margin and gap?

Yes. It works in properties that accept compatible numeric or length values, including font-size, padding, margin, gap, width and border-radius.

What viewport range should I enter?

Use the viewport widths where you want the value to reach the specified minimum and maximum. A common starting point is 360px to 1440px, but choose the range that matches your design and test smaller and larger screens.

Does CSS clamp replace every media query?

No. It is useful for continuously scaling a value between bounds. Media queries and container queries are still appropriate when layout structure or component behavior must change at a condition.

Next / Typography

Make responsive type feel intentional.

Learn how to choose the type size range, viewport endpoints and rem-based values for a readable fluid scale.

Read fluid typography ↗