Fluid Typography Clamp Generator
Solve CSS clamp() font sizes from your viewport and size anchors, then preview the emitted CSS at any width.
Size and viewport anchors
1 line · 550 charsThe base rem size drives every rem conversion — 10 px corresponds to a 62.5% root. Sizes shrink on wide screens when the maximum is smaller than the minimum; the generated clamp swaps its bounds so the ramp stays active.
Generated CSS
1 clamp · 3 decimalsfont-size: clamp(1rem, 0.786rem + 0.952vw, 1.5rem);
Flat sections are where the size is clamped at the minimum or maximum. Vertical marks are the viewport anchors.
Live preview
At 375 px: 16.1 px (calculated from the emitted values)
The preview scrolls horizontally at widths wider than this panel.
Details
Enter the font size at two viewport widths and the tool solves the linear interpolation behind CSS clamp(). It converts between px and rem using your root font size, emits rounded rem + vw values at 0–4 decimals, and previews the emitted CSS in an iframe sized to the chosen viewport. Type-scale mode renders a whole hierarchy as CSS custom properties or Tailwind fontSize theme keys.
More examples
Fluid body text
min 16px @ 360px, max 24px @ 1200px, precision 3
→ clamp(1rem, 0.786rem + 0.952vw, 1.5rem)The slope is 8 px of type over 840 px of viewport, giving 0.952vw; the intercept is 12.571px, or 0.786rem on a 16px root.
Full type scale as custom properties
:root {
--fs-display: clamp(2.5rem, 1.643rem + 3.81vw, 4.5rem);
--fs-body: clamp(1rem, 0.92rem + 0.357vw, 1.188rem);
}Every step uses the same viewport anchors but its own size pair, so the whole scale grows together without media-query jumps.
Shrinking headline
min 24px @ 360px, max 16px @ 1200px
→ clamp(1rem, 1.714rem - 0.952vw, 1.5rem)For a negative slope the clamp bounds are swapped: CSS resolves clamp(MIN, VAL, MAX) as max(MIN, min(VAL, MAX)), which would otherwise pin the text at 24px.
Examples
Canonical fluid body size
min 16px @ 360px, max 24px @ 1200px, base 16px, precision 3clamp(1rem, 0.786rem + 0.952vw, 1.5rem)0.952vw contributes 3.43 px at 360 px and 11.43 px at 1200 px; the 0.786rem intercept completes both anchors.
Shrinking display headline
min 24px @ 360px, max 16px @ 1200pxclamp(1rem, 1.714rem - 0.952vw, 1.5rem)The slope is negative, so the bounds are swapped. Without the swap CSS would clamp the value to the larger bound at every width.
Type scale as Tailwind v4 theme
scale mode, H1 32→56 px and Body 16→19 px at 360→1200 px@theme {
--text-h1: clamp(2rem, 1.357rem + 2.857vw, 3.5rem);
--text-body: clamp(1rem, 0.92rem + 0.357vw, 1.188rem);
}The v4 CSS-first theme uses --text-* variables; v3 would use fontSize keys in tailwind.config.js instead.
About this tool
Fluid typography replaces a ladder of media queries with one interpolation. You give the tool a font size at a narrow viewport and another at a wide viewport; it solves the line between them and emits a CSS clamp(min, fluid, max) declaration. For 16 px at 360 px and 24 px at 1200 px the slope is 8 / 840 = 0.00952 px of type per px of viewport, which becomes 0.952vw, and the intercept is 16 − 0.00952 × 360 = 12.571 px = 0.786rem on a 16 px root. The result is clamp(1rem, 0.786rem + 0.952vw, 1.5rem). Below 360 px the text holds at 1rem; above 1200 px it holds at 1.5rem.
The fluid term mixes rem and vw on purpose. The vw part scales with the viewport, while the rem part keeps that scaling anchored to the user's root font size — a reader who enlarges their browser's base font still gets larger text. Every rem value, including the base font size field, is converted through the root size you enter: 16 px is the common default, while 10 px corresponds to the popular 62.5% root setting. You can also emit px-only bounds for prototypes or email HTML where rem is unavailable.
Rounding is a real trade-off. The precision control offers 0–4 decimals, but rounding the rem intercept and the vw slope independently can move the ends of the ramp: at zero decimals the canonical example becomes clamp(1rem, 1rem + 1vw, 2rem), which computes to about 19.6 px at 360 px instead of 16 px. The tool reports that anchor error in pixels and adds a warning, so you can raise the precision until the emitted values match the anchors within your tolerance. The live readout is computed from the emitted rounded values, not from the exact intermediate math, so it never hides that drift.
A shrinking scale needs one extra correction. CSS resolves clamp(MIN, VAL, MAX) as max(MIN, min(VAL, MAX)): if you write clamp(1.5rem, fluid, 1rem), the lower bound is larger than the upper bound and the text stays pinned at 1.5rem. When the maximum size is smaller than the minimum size, the generator swaps the bounds and flips the vw term's sign. For 24 px at 360 px down to 16 px at 1200 px it emits clamp(1rem, 1.714rem - 0.952vw, 1.5rem), which really does shrink across the range.
Type-scale mode applies the same viewport pair to each step of a hierarchy — display through caption — and emits CSS custom properties or Tailwind fontSize keys. The preview renders the emitted CSS in an iframe sized to the chosen viewport width, so what you see is the actual declaration evaluated by the browser, and a curve under the code shows where the min and max plateaus begin. Everything runs in your browser tab; no sizes, text, or configurations are uploaded.
What this tool does not do
- Interpolates against viewport width only — container-query units (cqw) are a separate, intentionally unsupported output mode.
- The preview evaluates the emitted CSS at the slider's width; it is not a screenshot of your page and uses a system font stack.
- Very low precision settings can move the emitted ramp by several px at the anchors; the tool reports the error instead of silently correcting it.
How to use this tool
Set the four anchors
Enter the minimum and maximum font size plus the viewport widths where they apply. Use the px/rem toggles for each pair; rem inputs convert through the base rem size.
Choose precision and output
Pick 0–4 decimals, rem or px bounds, and CSS, Tailwind v3, or Tailwind v4 output. Watch the anchor-error warning if you use very low precision.
Switch to a type scale if needed
Turn on Type scale, rename the steps, and set a size pair for each one. Each row produces one clamp() line.
Preview and copy
Move the width slider to evaluate the emitted CSS in a real viewport-sized iframe, then copy the snippet or download it as a CSS or Tailwind file.
Share the configuration
Your values are mirrored into the URL, so a reload or a shared link restores the exact same settings.
Use cases
Responsive marketing pages
Replace breakpoint-by-breakpoint heading rules with one declaration that grows smoothly from phone to widescreen, with hard limits at both ends.
Design-system type scales
Codify display, heading, body, and caption steps from a single viewport pair, export them as custom properties, and keep the hierarchy proportional.
Auditing readability on small screens
Drag the preview to 375 px and see the computed px size together with a note when the emitted value drops below comfortable reading size.
Output shapes and what they mean
| Format | Example or rule |
|---|---|
| rem + vw (default) | clamp(1rem, 0.786rem + 0.952vw, 1.5rem) — scales with the viewport and respects the root font size |
| px + vw | clamp(16px, 12.571px + 0.952vw, 24px) — fixed rem basis for prototypes and non-rem codebases |
| CSS custom properties | :root { --fs-h1: clamp(2rem, 1.357rem + 2.857vw, 3.5rem); } — one variable per scale step |
| Tailwind v3 | theme.extend.fontSize keys in tailwind.config.js, e.g. "h1": "clamp(...)" |
| Tailwind v4 | @theme { --text-h1: clamp(...); } — the CSS-first theme syntax, not the v3 config syntax |
| Optional fallback | A preceding font-size: 16px declaration, or a duplicate custom property, for browsers without clamp() |
clamp() is supported by all current browsers; the fallback is for legacy environments only.
Common mistakes
Mistake:Writing clamp() with a larger first bound than last for a shrinking scale.
Fix:CSS treats clamp(MIN, VAL, MAX) as max(MIN, min(VAL, MAX)). Swap the bounds when the size decreases with the viewport; this tool does it automatically.
Mistake:Using pure vw for body text.
Fix:A pure vw value ignores the reader's root font-size preference. Keep a rem term in the middle expression, or generate px bounds only for contexts where rem truly is unavailable.
Mistake:Picking zero decimals and expecting the anchors to survive.
Fix:Rounding the intercept and slope independently shifts the endpoints. Check the reported anchor error and use three or four decimals when the ramp must hit its anchors closely.
Mistake:Claiming WCAG requires a 16 px minimum font size.
Fix:WCAG 1.4.4 concerns text resizing at 200%, not a minimum px size. Treat 16 px at phone widths as a legibility guideline and judge it in the context of your design.
Frequently asked questions
How does the clamp() fluid formula work?
The generator solves a straight line through your two anchor pairs. The slope is (maximum size − minimum size) / (maximum viewport − minimum viewport), expressed as vw by multiplying by 100. The intercept is minimum size − slope × minimum viewport, converted to rem by dividing by the root font size. The emitted declaration is clamp(minimum, intercept + slope vw, maximum), so the text grows linearly between the viewports and holds flat outside them. For 16 px at 360 px and 24 px at 1200 px that is clamp(1rem, 0.786rem + 0.952vw, 1.5rem).
Why use rem + vw instead of pure vw?
Pure vw ignores the reader's browser font-size setting: at 100vw, 2vw is the same pixel size for everyone. A rem term in the middle expression keeps the ramp tied to the root font size, so readers who enlarge their default font still get larger text. The tool converts every rem value through the base rem size field — 16 px normally, or 10 px for a 62.5% root. If you genuinely need px-only bounds, switch the output unit to px; the vw term remains viewport-relative either way.
What happens below the minimum or above the maximum viewport?
Nothing changes: clamp() holds the value at the nearest limit. Below the minimum viewport the text is the minimum size, and above the maximum viewport it is the maximum size. The preview slider extends past both anchors so you can see those plateaus, and a note appears when the selected width is outside the range. The small chart under the code shows the same flat sections and marks both anchor positions.
Can type shrink as screens get bigger?
Yes. Set the maximum size lower than the minimum size and the generator emits a negative vw slope. It also swaps the clamp bounds, which is essential: CSS resolves clamp(MIN, VAL, MAX) as max(MIN, min(VAL, MAX)), so clamp(1.5rem, fluid, 1rem) would be pinned at 1.5rem forever. The correct output for 24 px at 360 px shrinking to 16 px at 1200 px is clamp(1rem, 1.714rem - 0.952vw, 1.5rem).
Why does low precision move my anchor values?
The intercept and the slope are rounded independently. At zero decimals the canonical 16→24 px example becomes clamp(1rem, 1rem + 1vw, 2rem), which computes to about 19.6 px at 360 px instead of 16 px. The tool reports the largest resulting anchor error in px and warns you when it exceeds half a pixel. Raise precision to three or four decimals when the endpoints must be exact; the readout always reflects the emitted rounded values, not the unrounded math.
How do I use the output in Tailwind?
Pick the output that matches your Tailwind major version. Tailwind v3 uses JavaScript config keys under theme.extend.fontSize, such as "h1": "clamp(2rem, 1.357rem + 2.857vw, 3.5rem)". Tailwind v4 uses the CSS-first @theme block with --text-* variables, such as --text-h1: clamp(...). The two syntaxes are not interchangeable, so the generator emits only the one you select. In plain CSS, type-scale mode emits custom properties under :root instead.
Does the preview actually evaluate the CSS it generates?
Yes. The preview iframe is sized to the selected viewport width and contains the emitted clamp() declaration applied to your own sample text, so the browser evaluates the same string you copy. The px readout is read from that iframe's computed font-size when possible and otherwise calculated from the rounded emitted coefficients — never from separate, optimistic math. The page does not fetch fonts and does not send your values anywhere.
References & standards
Related tools
Aspect Ratio Calculator
Calculate dimensions and ratios for images and videos.
Border Radius Generator
Visually craft CSS border-radius values — including the advanced 8-value slash syntax for organic blob shapes — with a live preview and one-click copy.
Box Shadow Generator
Visual CSS box-shadow generator. Create beautiful shadows with live preview and copy the CSS code.
CSS :has() Selector Playground
Try the CSS :has() parent selector on live editable HTML and CSS, with ten patterns, dropped-rule detection and specificity notes.
CSS Button Generator
Design buttons with hover, active, focus-visible and disabled states — gradients, shadows, borders, icons — and copy clean CSS or Tailwind.
CSS Clip-Path Generator
Draw clip-path shapes visually: drag polygon points, tune circle/ellipse/inset presets, paste an SVG path and copy responsive CSS.