Fluid Type Scale Generator

Build a whole type scale in one go: pick a body size, a ratio, and how many steps you want above and below it, and get a block of CSS custom properties where every step is its own fluid clamp(). The distinctive part is the two ratios. Most generators take one, and one is usually wrong somewhere — a 1.618 golden-ratio scale that looks striking on a desktop puts a 180px heading on a phone that has nowhere to put it. Setting a tighter ratio for small screens and a looser one for large means the relationships between your sizes change with the viewport, not just the sizes themselves. Every step uses rem bounds, so the scale still responds to a reader who has increased their default text size. If you only need one fluid value rather than a whole scale, the CSS Clamp Generator does that.

Common ratios

RatioNameCharacter
1.125Major secondVery subtle — dense interfaces
1.2Minor thirdA safe default for UI
1.25Major thirdClear hierarchy, still compact
1.333Perfect fourthEditorial, generous
1.5Perfect fifthStrong contrast
1.618Golden ratioDramatic — needs a large screen

When to use it

  1. Set up the type scale for a new design system.
  2. Replace a pile of font-size media queries with named variables.
  3. Make headings tighter on mobile without writing breakpoints.
  4. Generate a matching fluid spacing scale.
  5. Compare how different ratios feel before committing.

How to Use

  1. Set your body size at each end of the viewport range.
  2. Pick a ratio for small screens and one for large.
  3. Copy the custom properties into your stylesheet.

Features

  1. Separate ratios for narrow and wide viewports
  2. Every step is its own fluid clamp()
  3. rem bounds that respect user font settings
  4. Steps above and below the base
  5. Named CSS custom properties, prefix sanitised
  6. Live preview of the whole scale

FAQs

What is a modular scale?

A set of sizes where each is the previous one multiplied by a fixed ratio. It borrows from musical intervals — 1.5 is a perfect fifth, 1.333 a perfect fourth — and the point is that the sizes relate to each other by a consistent rule, which reads as deliberate rather than arbitrary.

Why two ratios instead of one?

Because a ratio that works on a desktop usually does not work on a phone. Five steps up from 16px at a 1.618 ratio is over 180px — fine on a large screen, impossible on a 375px-wide one. A tighter ratio at the narrow end keeps the scale usable, and because each step is a clamp, the ratio itself changes smoothly with the viewport.

Which ratio should I pick?

1.2 or 1.25 for most interfaces — enough contrast to establish hierarchy without dominating the page. 1.333 and up suits editorial layouts with large display headings. 1.618 is dramatic and needs room. The preview shows the effect immediately, which is a better guide than the numbers.

Why are the values in rem?

So the scale respects the reader's own font setting. A scale built from px or bare vw units ignores it entirely, which means someone who has increased their default text size gets no benefit — an accessibility failure under WCAG 1.4.4, not a stylistic question.

How do I use the custom properties?

Paste the :root block into your stylesheet and reference the steps by name — font-size: var(--step-2) for a heading, var(--step-base) for body text. Naming the steps is what makes a scale maintainable; changing the ratio later then updates everything at once.

Can I use this for spacing as well as type?

Yes, and it is worth doing. A spacing scale built on the same ratio makes margins and padding relate to the type, which is most of what makes a layout feel coherent. Change the prefix to something like space and use a smaller base.

Technical Details

A modular scale multiplies each step by a fixed ratio, so sizes relate to one another the way musical intervals do rather than being picked individually — which is what makes a set of headings look deliberate instead of arbitrary. This generator takes two ratios rather than one, and that is the point of it. A single ratio that looks striking on a desktop is wrong on a phone: at 1.618, five steps above a 16px body gives a heading of over 180px, which no phone can hold. Applying a tighter ratio at the narrow end and a looser one at the wide end means the scale itself becomes fluid, not just each individual size. Every step is then emitted as its own clamp(), computed from its own pair of endpoints, with rem bounds so the whole scale still responds to the reader's font setting — a scale built from px or bare vw units ignores it completely and fails WCAG 1.4.4. The output is a block of CSS custom properties rather than loose values, because a scale is only useful if the steps are referenced by name; the prefix is sanitised into a legal custom property name, since a space or a stray character silently invalidates the declaration and the variable simply resolves to nothing.

Web & CSS Tools

Web & CSS Tools

  • CSS Flexbox Generator
  • CSS Grid Generator
  • CSS Border Radius Generator
  • CSS Box Shadow Generator
  • Cubic Bezier Generator
  • CSS Clip Path Generator
  • CSS Keyframes Generator
  • CSS Unit Converter