Typography
Font families, type scale, and text styles for consistent, readable interfaces
Typography System
UI Lab has two typography layers: a compact, role-based contract for components and the .typography reading surface for long-form document flow. They share the same theme scale, but components should not borrow document spacing or heading rules.
Font Families
Primary (Sans): System fonts for native appearance, better performance, and accessibility
Secondary (Monospace): For code, data tables, and technical content
Component Typography Contract
Components use three font-family roles: --font-body for controls, labels, captions, and supporting copy; --font-heading for component titles; and --font-mono for code and data. Sizes, weights, and leading remain on the existing type-scale tokens (--text-*, --font-weight-*, and --leading-*) so the API stays small.
Controls keep the compact --text-sm / --leading-sm pairing, which preserves Button and Group sizing. Headings use --header-text-* with --leading-heading; code and data use --text-code-size with --leading-code.
.typography is intentionally different: it owns document rhythm, prose headings, lists, code blocks, and tables on a reading surface. It is not the default styling API for controls.
Type Scale
1.25 ratio (perfect fourth) provides clear hierarchy without too many sizes
Font Sizes
Font Weights
Three primary weights provide sufficient contrast without excessive variety:
Weight Usage Guidelines
Regular (400)
- Primary body text
- Paragraphs, descriptions
- Default state for all text
Medium (500)
- Labels and form text
- Navigation items
- Subheadings
- Emphasized content
- Button labels
Bold (700)
- Heading levels (h1-h6)
- Strong emphasis within body text
- Important labels or badges
- Section titles
Line Heights
Line height affects readability and visual rhythm:
Line Height Guidelines
Tight (1.25)
- Headings and display text
- Badges and labels
- Compact information
Normal (1.5)
- Body paragraphs
- Descriptions and explanatory text
- Standard content blocks
- Forms and form labels
Relaxed (1.75)
- Long-form articles
- Accessibility-critical content
- Content designed for readability
Text Styles
Predefined text styles combine font size, weight, line height, and letter spacing for common patterns.
Heading Styles
Heading 1 (h1)
- Size: 2.25rem (36px)
- Weight: 700 (bold)
- Line Height: 1.25
- Use: Page titles, primary headings
- CSS Variable:
--text-h1
Heading 2 (h2)
- Size: 1.875rem (30px)
- Weight: 700 (bold)
- Line Height: 1.25
- Use: Section titles, major divisions
- CSS Variable:
--text-h2
Heading 3 (h3)
- Size: 1.5rem (24px)
- Weight: 700 (bold)
- Line Height: 1.5
- Use: Subsections, component headings
- CSS Variable:
--text-h3
Heading 4 (h4)
- Size: 1.25rem (20px)
- Weight: 700 (bold)
- Line Height: 1.5
- Use: Minor headings, group titles
- CSS Variable:
--text-h4
Body Styles
Body Large
- Size: 1rem (16px)
- Weight: 400 (regular)
- Line Height: 1.5
- Use: Lead paragraphs, important content
- CSS Variable:
--text-body-lg
Body (Default)
- Size: 1rem (16px)
- Weight: 400 (regular)
- Line Height: 1.5
- Use: Standard body text, paragraphs
- CSS Variable:
--text-body
Body Small
- Size: 0.875rem (14px)
- Weight: 400 (regular)
- Line Height: 1.5
- Use: Secondary text, descriptions
- CSS Variable:
--text-body-sm
UI Styles
Label
- Size: 0.875rem (14px)
- Weight: 500 (medium)
- Line Height: 1.25
- Use: Form labels, UI text, badges
- CSS Variables:
--font-body,--text-sm,--font-weight-body-medium,--leading-sm
Caption
- Size: 0.75rem (12px)
- Weight: 400 (regular)
- Line Height: 1.25
- Use: Metadata, timestamps, hints
- CSS Variables:
--font-body,--text-xs,--font-weight-body-normal,--leading-sm
Code
- Font Family: Monospace
- Size: 0.875rem (14px)
- Weight: 400 (regular)
- Line Height: 1.5
- Use: Inline code, code blocks
- CSS Variables:
--font-mono,--text-code-size,--font-weight-code,--leading-code
Usage
Line length: 45-75 characters optimal, max 90
Contrast: Minimum 4.5:1 for normal text, 3:1 for large text (18pt+)
Responsive: Adjust sizes down one step on tablet, increase line height slightly on mobile
CSS Variable Usage
All typography styles are available as CSS variables:
Tailwind CSS Classes
Typography is integrated with Tailwind:
Accessibility
- Minimums: Body text 16px, labels 14px, captions 12px
- Line height: Minimum 1.5 for body text
- Testing: Verify contrast ratios, test with screen readers, check at 200% zoom