| name | typography-scale |
| description | Mathematical typography scale system. Generates harmonious type hierarchies using golden ratio, perfect fifth, and other classical scales. Handles font pairing, line-height binding, CJK/special character spacing, and system font optimization. Sources: type-scale.com, google/fonts, braid-design-system, guardian/frontend, nytimes/typography, and 5 others. |
/typography-scale
When to Use
- Establishing type hierarchy for a new project
- Fixing inconsistent font sizes ("these headings feel random")
- Optimizing for readability on long-form content
- Adding CJK/Vietnamese/Arabic language support
Do NOT use for
- Single-page microsites with one font size
- Data tables (use monospace + fixed sizing instead)
Classical Scale Ratios (type-scale.com)
Golden Ratio : 1.618 â dramatic hierarchy, editorial
Perfect Fifth : 1.500 â strong, classic
Augmented Fourth: 1.414 â modern, balanced (â2)
Major Third : 1.250 â subtle, content-heavy
Minor Third : 1.200 â dense UI, dashboards
Major Second : 1.125 â very tight, data-heavy
Scale generation from base (16px default)
function typeScale(base = 16, ratio = 1.25, steps = 6) {
return Object.fromEntries(
Array.from({ length: steps }, (_, i) => [
`step-${i}`,
`${(base * Math.pow(ratio, i - 1)).toFixed(2)}px`
])
)
}
Semantic Naming (Braid + Guardian)
:root {
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.25rem;
--text-xl: 1.563rem;
--text-2xl: 1.953rem;
--text-3xl: 2.441rem;
--text-4xl: 3.052rem;
}
Line-Height Binding (Braid Design System rule)
Line-height must scale with font size â never use a fixed value:
p { font-size: var(--text-3xl); line-height: 1.5rem; }
--lh-tight: 1.2;
--lh-normal: 1.5;
--lh-loose: 1.8;
h1 { font-size: var(--text-3xl); line-height: var(--lh-tight); }
p { font-size: var(--text-base); line-height: var(--lh-normal); }
Font Pairing Principles (google/fonts)
Best-practice pairing patterns:
- Contrast in classification â Serif heading + Sans body (NYT, Guardian)
- Same superfamily â Inter Display + Inter Text
- Geometric + Humanist â Futura heading + Gill Sans body
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Source+Serif+4:ital,wght@0,400;1,400&display=swap');
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, sans-serif;
CJK / Vietnamese / Special Character Spacing (sparanoid)
:lang(vi) {
line-height: 1.7;
word-spacing: 0.05em;
}
:lang(zh), :lang(ja), :lang(ko) {
overflow-wrap: anywhere;
line-break: strict;
}
Font Smoothing (rasmusbe)
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.dark-bg { -webkit-font-smoothing: subpixel-antialiased; }
Skimmability Rules (NYT pattern)
Long-form content must support visual scanning:
- First 3 words of paragraph carry the meaning
- Drop caps or pull quotes every 400 words
- Headers every 200â300 words maximum
- No paragraph longer than 100 words
Anti-Pattern Checklist
â Font sizes not from scale (font-size: 13px, 17px, 22px)
â Fixed line-height in px on headings
â More than 3 font families in one project
â CJK text with line-height < 1.6
â Body text smaller than 16px on desktop
â Missing system font fallback (custom font only)