Text Size
Typography size scale based on the Golden Ratio for visual harmony.
The Magic Ratio
The ratio used for creating visual harmony is the Golden Ratio, which is 1.618. This mathematical calculation is what makes interfaces, like Apple's, feel "right" to users' eyes.
Typography Scale
Our typography system uses CSS variables based on the Golden Ratio, with additional intermediate sizes for flexibility.
| Class | Size | Pixels | Use Case |
|---|---|---|---|
text-2xs | 0.625rem | 10px | Micro labels, badges |
text-xs | 0.75rem | 12px | Captions, timestamps |
text-sm | 0.875rem | 14px | Secondary text, meta |
text-base | 1rem | 16px | Body text (base) |
text-md | 1.125rem | 18px | Lead paragraphs |
text-lg | 1.25rem | 20px | Large body text |
text-xl | 1.625rem | 26px | H4, subheadings |
text-2xl | 2rem | 32px | H3, small titles |
text-3xl | 2.625rem | 42px | H2, section titles |
text-4xl | 3.5rem | 56px | H1, page titles |
text-5xl | 4.25rem | 68px | Display, hero |
text-6xl | 5.5rem | 88px | Large display |
text-7xl | 6.875rem | 110px | Extra large display |
Bold values represent the core Golden Ratio scale (16 → 26 → 42 → 68 → 110).
Golden Ratio Calculation
16 × 1.618 = 26
26 × 1.618 = 42
42 × 1.618 = 68
68 × 1.618 = 110
CSS Variables
All sizes are defined as CSS variables in globals.css:
:root {
/* Smaller sizes */
--text-2xs: 0.625rem; /* 10px */
--text-xs: 0.75rem; /* 12px */
--text-sm: 0.875rem; /* 14px */
/* Base */
--text-base: 1rem; /* 16px */
/* Larger sizes */
--text-md: 1.125rem; /* 18px */
--text-lg: 1.25rem; /* 20px */
--text-xl: 1.625rem; /* 26px */
--text-2xl: 2rem; /* 32px */
--text-3xl: 2.625rem; /* 42px */
--text-4xl: 3.5rem; /* 56px */
--text-5xl: 4.25rem; /* 68px */
--text-6xl: 5.5rem; /* 88px */
--text-7xl: 6.875rem; /* 110px */
}Line Heights
Each text size has an optimized line-height:
| Size Range | Line Height | Variable |
|---|---|---|
| Display (5xl-7xl) | 1 | --leading-none |
| Headings (3xl-4xl) | 1.25 | --leading-tight |
| Subheadings (xl-2xl) | 1.375 | --leading-snug |
| Body (base-lg) | 1.625 | --leading-relaxed |
| Small (2xs-sm) | 1.5 | --leading-normal |
Usage Examples
Headings
<h1 class="text-5xl">Hero Heading</h1>
<h2 class="text-3xl">Section Title</h2>
<h3 class="text-2xl">Subsection</h3>
<h4 class="text-xl">Minor Heading</h4>Body Text
<p class="text-base">Regular body text for content.</p>
<p class="text-lg">Lead paragraph for introductions.</p>
<p class="text-sm text-muted-foreground">Secondary information.</p>Small Text
<span class="text-xs">Caption or timestamp</span>
<span class="text-2xs">Micro label or badge</span>Best Practices
- Stick to the scale - Avoid arbitrary sizes between tiers
- Hierarchy matters - Larger = more important
- Consistency - Use the same size for the same purpose across pages
- Line height - Larger text needs tighter leading, smaller text needs looser
- Responsive - Consider reducing sizes on mobile by one step