Typography is the art and technique of arranging type to make written language legible, readable, and appealing. A well-designed typography system creates visual hierarchy and improves content comprehension.
System fonts provide the fastest loading experience and familiar appearance across platforms.
/* Recommended modern stack */
body {
font-family:
/* macOS & iOS */
-apple-system,
BlinkMacSystemFont,
/* Windows */
"Segoe UI",
/* Android */
Roboto,
/* Linux */
Ubuntu,
/* Generic fallbacks */
Cantarell,
"Helvetica Neue",
sans-serif;
}Using the generic system-ui:
body {
font-family: system-ui, sans-serif;
}Choose a type scale for consistent sizing:
:root {
/* Major Third (1.25) */
--font-size-xs: 0.64rem; /* 10.24px */
--font-size-sm: 0.8rem; /* 12.8px */
--font-size-base: 1rem; /* 16px */
--font-size-md: 1.25rem; /* 20px */
--font-size-lg: 1.563rem; /* 25px */
--font-size-xl: 1.953rem; /* 31.25px */
--font-size-2xl: 2.441rem; /* 39.06px */
--font-size-3xl: 3.052rem; /* 48.83px */
}const typography = {
h1: {
fontSize: '3.052rem',
lineHeight: 1.2,
fontWeight: 700,
},
h2: {
fontSize: '2.441rem',
lineHeight: 1.3,
fontWeight: 700,
},
h3: {
fontSize: '1.953rem',
lineHeight: 1.4,
fontWeight: 600,
},
h4: {
fontSize: '1.563rem',
lineHeight: 1.4,
fontWeight: 600,
},
body: {
fontSize: '1rem',
lineHeight: 1.5,
fontWeight: 400,
},
small: {
fontSize: '0.8rem',
lineHeight: 1.5,
fontWeight: 400,
},
};See Assets/Fonts.md for comprehensive font loading strategies.
<!-- Preload critical fonts -->
<link rel="preload" href="/fonts/inter-regular.woff2" as="font" type="font/woff2" crossorigin>
<!-- Load fonts with fallback -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">Heading + Body Combination:
/* Pair 1: Sans-serif + Sans-serif */
.heading {
font-family: 'Inter', sans-serif;
font-weight: 700;
}
.body {
font-family: 'Inter', sans-serif;
font-weight: 400;
}
/* Pair 2: Serif + Sans-serif */
.heading {
font-family: 'Merriweather', serif;
}
.body {
font-family: 'Inter', sans-serif;
}
/* Pair 3: Display + Sans-serif */
.heading {
font-family: 'Playfair Display', serif;
}
.body {
font-family: 'Source Sans Pro', sans-serif;
}function TypePairing({ headingFont, bodyFont }) {
return (
<div>
<h1 style={{ fontFamily: headingFont }}>
Heading Font
</h1>
<p style={{ fontFamily: bodyFont }}>
Body font should be readable at all sizes and complement the heading font.
</p>
</div>
);
}/* Scales smoothly between breakpoints */
h1 {
font-size: clamp(2rem, 5vw, 3rem);
}
p {
font-size: clamp(1rem, 2.5vw, 1.125rem);
}h1 {
font-size: 2rem;
}
@media (min-width: 768px) {
h1 {
font-size: 2.5rem;
}
}
@media (min-width: 1024px) {
h1 {
font-size: 3rem;
}
}Optimal reading line length: 45-75 characters
p {
max-width: 65ch; /* Approximately 65 characters */
}body {
line-height: 1.5; /* Comfortable for body text */
}
h1, h2, h3 {
line-height: 1.2; /* Tighter for headings */
}Minimum readable size: 16px for body text
body {
font-size: 16px; /* Base size */
}
.small-text {
font-size: 14px; /* Minimum for secondary text */
/* Never go below 14px for readable text */
}Use 2-3 font families maximum.
/* Don't use too many weights */
font-weight: 400; /* Normal */
font-weight: 600; /* Semibold for emphasis */
font-weight: 700; /* Bold for headings *//* Body text */
line-height: 1.5;
/* Headings */
line-height: 1.2;/* Headings (tighter) */
h1, h2 {
letter-spacing: -0.02em;
}
/* Body (normal) */
body {
letter-spacing: 0;
}
/* ALL CAPS (wider) */
.caps {
letter-spacing: 0.1em;
text-transform: uppercase;
}- Assets Guide - Asset management
- Style Guide - Typography in components