Fluid Typography Toolkit

CSS clamp() Fluid Type Scale Calculator

Generate production-ready clamp() values, a full fluid type scale, fluid spacing tokens, and a Tailwind config export in one place. Type scales resize smoothly between viewports with no media queries and no JavaScript.

clamp() vs min() and max(): When Each One Earns Its Place

min() is a ceiling, max() is a floor, clamp() is a corridor: the mental models and worked examples for reaching for the right CSS function.

1Single clamp() value

Define the smallest and largest size and the viewports they belong to. The tool interpolates a fluid value between them.

font-size: clamp(1rem, 0.6522rem + 2.1739vw, 3rem);

2Full fluid type scale

Pick a base size and a ratio. Every step gets its own fluid clamp() value plus a line-height suggestion.

The type scale compresses toward the base at the small viewport (times the first factor) and opens up at the large viewport (times the second). One factor pair, applied to every step.

Type scale output

Click any row to copy. Copy All grabs the full CSS custom-property block.

StepMin / Max (px)Line-heightclamp() value
Advertisement slot — leaderboard

Live resizable preview

Drag the slider or the corner handle to resize the preview and watch every step fluidly rescale. Line-heights are applied.

Preview width: 760px  ·  rendered font sizes measured by the browser

3Fluid spacing tokens

Spacing that breathes with the viewport, built from your base size. Drop straight into custom properties.

4Line-height suggestions

How the suggested line-heights are chosen. They ship in the table above and in every export.

  • Body text (steps 0 and below): 1.5 to 1.65 for comfortable long-form reading.
  • Headings (steps +1 to +3): 1.2 to 1.35, tight enough to read as a unit.
  • Display sizes (steps +4 and up): 1.05 to 1.15, editorial-style tightness.
  • Values are unitless so they scale with whatever fluid size is applied.
  • Also consider text-wrap: balance on display headings for cleaner line breaks.

Export

Tailwind v3 config theme extension, Tailwind v4 @theme tokens, and the raw :root block. Each uses your scale settings.

Advertisement slot — rectangle

What is fluid typography?

Fluid typography makes font sizes grow and shrink smoothly with the viewport instead of jumping between fixed sizes at breakpoints. In CSS, the clamp() function does the heavy lifting: clamp(minimum, preferred, maximum) picks a preferred value that scales with the viewport, but never goes below the minimum or above the maximum.

How clamp() works

The preferred value is usually a calculation like 1.2rem + 2.5vw: a fixed base plus a viewport-relative term. At your minimum viewport width it resolves to your minimum size; at your maximum viewport it resolves to your maximum size. Everywhere in between, it interpolates linearly. This calculator derives the exact intercept and slope so the line passes through both of your endpoints.

Why a type scale beats a single size

Accessibility notes

Frequently asked questions

What is the CSS clamp() function?

clamp(min, val, max) resolves to val unless it is smaller than min or larger than max. For typography, val is usually a calc combining a fixed term and a vw term, which makes the size fluid between the two endpoints.

How do I convert px to rem in clamp()?

Divide by your root font size, almost always 16. So 24px becomes 1.5rem. This calculator outputs rem by default because rem respects the user's browser text-size preference, which matters for accessibility.

What viewport range should I use?

A common pair is 360px (small phones) to 1280px (laptops). Sizes below 360px are rare enough that the minimum bound handles them; sizes above 1280px are handled by the maximum bound, so giant monitors don't get giant text.

Which type scale ratio should I pick?

1.333 (perfect fourth) is the safest default: noticeable hierarchy without melodrama. Use 1.25 for dense, content-heavy UIs and 1.5 or 1.618 when you want editorial drama. This tool previews every step, so try ratios and watch the preview.

Does clamp() work in all browsers?

clamp() is supported in all modern browsers released since 2020 (Chrome 79+, Firefox 75+, Safari 13.1+, Edge 79+). For older browsers you can add a fixed-size fallback declaration before the clamp() line; browsers that understand clamp() will override it.

Can I use fluid type with Tailwind?

Yes. Paste this tool's Tailwind v3 config snippet into theme.extend.fontSize for utilities like text-step-3, or use the v4 @theme tokens in your CSS. Both export tabs generate the code from your current settings.

Guides

CSS clamp() for Fluid Navigation Font Size: Links That Fit From Phone to Desktop

CSS clamp() for fluid navigation menu font size: one line holds nav links between 14px and 18px, fluid from 400px to 1200px, with a fluid gap to match.

CSS clamp() for Fluid Container Max Width: One Line Instead of a Breakpoint Ladder

CSS clamp() for fluid container max width replaces a ladder of media queries with one width line: a floor for small phones, a viewport-relative middle, and a ceiling that keeps lines readable.

CSS clamp() for Fluid Hero Section Height: A Hero That Scales Without Breakpoints

CSS clamp() for fluid hero section height fixes the two classic hero failures: a fixed height that crowds desktop and a 100vh hero that swallows a phone screen. One min-height line, three values, no breakpoints.

CSS clamp() for Fluid Sidebar Width: A Sidebar That Scales Without Breakpoints

One grid track that holds a sidebar between 220px and 360px, the vw trap that breaks sidebars, and the stacking fix for small screens.

CSS clamp() for Fluid Image Width: Responsive Images Without Breakpoints

One clamp() line holds hero and card images between a floor and a ceiling, with the container trap explained.

CSS clamp() for Fluid Grid Gap: Responsive Gutters Without Breakpoints

One clamp() line keeps card gutters tight on phones and generous on desktops, with separate row and column gaps.

Fluid Border Radius with CSS clamp(): Corners That Scale

Fixed pixel radii look tiny on desktop and chunky on phones. One clamp() line scales the corners between your tokens, with the percentage pitfall explained.

CSS clamp() for Responsive Button Padding: The Fluid Button Recipe

One clamp() line for button padding, one for the font size, and the em trick that keeps the two in proportion. The touch target floor and a worked recipe.

Should you swap vw for dvw inside clamp()?

The going advice says to use clamp() with dvw instead of vw for mobile fluid layouts. The width math says otherwise; the height math is where the swap earns its keep.

CSS clamp() With em in the Preferred Value: Components That Scale Themselves

Put em in the middle slot and the whole clamp rides on the component's font size. When it helps, when rem is better, and the nesting trap.

Fluid Type Scale With CSS clamp(): Building It From a Modular Ratio

Let the ratio pick the sizes and clamp() make them fluid. The modular scale math, the 2-ratio trick behind Utopia's generator, and real scale output values.

Can You Nest clamp() Inside calc()? Nesting Rules With Examples

Both directions nest fine, but each has a natural job. calc() inside clamp() for mixed-unit preferred values, clamp() inside calc() when you subtract a fixed offset from a fluid value.

Converting Media Queries to clamp(): What to Convert and What to Leave Alone

One clamp() line replaces three stepped media queries for sizes and spacing. The linear-interpolation formula and the layout decisions you should not touch.

Why Your clamp() Never Reaches Its Max: The Crossover Viewport Math

Two divisions tell you exactly which viewports ever see the fluid middle of your clamp(). Worked out on three real snippets, including the popular body-text one.

Can You Use CSS clamp() Inside Custom Properties? Yes, With One Catch

The short answer is yes, in both directions. Storing the whole clamp() in a variable is how I run type scales now. There is one catch, and it is about animation.

A CSS clamp() Fluid Heading Scale for H1 to H3 That Holds Together

One scale, three headings, no breakpoints. The clamp values and the ratio that keep H1, H2, and H3 in proportion.

The clamp() Preferred Value Formula, Worked Through by Hand

The preferred value in clamp() is the equation of a line. Two endpoints, slope, intercept, worked through with real numbers, plus the thirty-second check that catches slips.

How to Combine clamp() and calc() in CSS

For years I nested calc() inside every clamp() out of habit. When the nesting is optional, when it is required, and the mistakes that silently break calc().

CSS clamp() With Container Query Units: Fluid Type That Scales to Its Container

Viewport units do not know where your component lives. Container query units do. How to make clamp() type respond to the card instead of the screen.

Should Your Card Grid Use clamp()? Fluid Card Widths, Three Ways

When clamp earns its place on card widths, when auto-fit minmax wins, and the decision rules for picking between them.

Fluid Line Height With clamp(): When to Bother and the Legal Way to Do It

Unitless line-height values cannot go inside clamp(). The em-based formula that can, a worked example, and why I rarely bother.

Should Your clamp() Values Use rem or px? Where the Unit Actually Matters

Min and max should be rem. The preferred value is where the argument lives. Here is the zoom math, the one place px is fine, and the 2.5x ceiling rule.

CSS clamp() and Browser Zoom: Why Pure vw Units Fail Accessibility

Pure vw ignores browser zoom, failing WCAG 1.4.4. The rem + vw formula that keeps fluid type accessible, with the demo numbers.

Using CSS clamp() for Fluid Spacing: Padding, Margins, and Gaps That Scale Themselves

Fluid section padding, card gutters, and grid gaps that scale with the viewport, plus the rule for which spacing stays fixed.

CSS clamp() Fallbacks for Older Browsers: Two Methods That Work

Two fallback approaches for clamp(): the static declaration above, and the @supports not block. Plus the IE11 edge case that breaks the fancy one.

CSS clamp(), Finally Explained: Min, Preferred, and Max

How the browser resolves min, preferred, and max, with a worked fluid-type example and the rem accessibility rule.

Fluid Typography vs Media Queries: When to Use clamp()

When one line of clamp() replaces four breakpoints, and when media queries still win.

Copied

Get new free tools by email

One short email when a useful new calculator or dataset launches. No spam, unsubscribe anytime.

Subscribe free