Fluid type clamp() calculator

Pick a size at a small viewport and a size at a wide one and get the clamp() that glides between them, as CSS, a Tailwind arbitrary value or an @theme token, read out at five real widths.

375px wide16.46px
768px wide19.73px
1024px wide21.87px
1440px wide24px
1920px wide24px
preview at this window

Ship the interface, keep the code

fluid.csscss
font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem);
The middle value mixes rem and vw on purpose. With vw alone the size is pinned to the window, so a reader who zooms in gets exactly what they had before. The rem part is what lets the text follow their setting.
Made something you like?Hero blocks to set it on

Questions

Why is there a rem part in the middle value?+

A preferred value written in vw alone is pinned to the window, so a reader who zooms in with the browser gets exactly the size they had before, which fails accessibility audits. Adding the rem intercept lets the value scale with their font setting while still following the viewport.

What viewports should I use?+

The two ends where you stop caring: a small phone at around 320 to 375px and the widest layout you design for, often 1280 or 1440px. Between them the size is a straight line; outside them it is clamped, so wider screens never get comically large type.

Does this work for spacing too?+

Yes. clamp() is a length, so the same expression works for padding, gap or a max-width. Paste the CSS into any property, or drop the @theme token into --spacing-fluid and use it as a utility.

Related tools

The tools are free. So is most of the library.

2095 blocks and 1076 pieces for shadcn/ui and Tailwind, built on the same tokens these tools write. Install one with a command and the code is yours.

No signup for the tools. MIT for free blocks, commercial licence for Pro.

Markdown version