Skip to content

Design

CSS Clamp Calculator

Generate a fluid CSS clamp expression from minimum and maximum sizes and viewport widths.

How to use this tool
  1. Enter minimum and maximum sizes in pixels.
  2. Set the two viewport widths and root font size.
  3. Copy the fluid clamp expression.

Loading tool…

About this tool

What is CSS Clamp Calculator?

Create a fluid size that grows between two viewport widths while staying within chosen minimum and maximum values. This is useful for a heading or spacing token that should change smoothly rather than jump at breakpoints. The calculation assumes a root font size for the rem conversion; the actual stylesheet and the user's browser settings still affect the rendered result.

A worked example

Grow from 16 to 24 pixels between 400 and 1200 pixels

Example input

16 → 24 px
400 → 1200 px
1rem = 16px

Expected result

clamp(1rem, 0.75rem + 1vw, 1.5rem)

At a viewport width of 400 pixels, one vw is four pixels, so the middle expression is 12 plus 4. At 1200 pixels it is 12 plus 12. Outside that interval, clamp keeps the value at the minimum or maximum. Test intermediate widths as well as the endpoints, especially when a longer translated heading can wrap unexpectedly.

Common mistakes and limits

  • The root font size entered here is an assumption, not a measurement of the destination page. Check the actual rem definition before copying a result.
  • Fluid sizing does not by itself guarantee accessible zoom or prevent overflow. Test browser zoom, long content and narrow viewports in the final layout.

Features

What you can do

  • Fluid typography and spacing
  • Explicit viewport range
  • Pixel or rem limits
  • Shows the linear interpolation formula

Frequently asked questions

Questions about CSS Clamp Calculator

What does the root font size affect?

It converts the size bounds and intercept from pixels to rem. If the actual root font size changes, rem-based output scales with that setting.

Related tools