home / skills / petekp / claude-code-setup / typography

typography skill

/skills/typography

This skill helps you apply professional typography principles to create readable, balanced interfaces with clear hierarchy and effective measure.

npx playbooks add skill petekp/claude-code-setup --skill typography

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
8.5 KB
---
name: typography
description: Apply professional typography principles to create readable, hierarchical, and aesthetically refined interfaces. Use when setting type scales, choosing fonts, adjusting spacing, designing text-heavy layouts, or when the user asks about readability, font pairing, line height, measure, or typographic hierarchy.
---

# Typography

Professional typography for user interfaces.

## Output Contract

For type system recommendations:

```markdown
## Type System

### Scale
- Base: [size, e.g., 16px]
- Ratio: [e.g., Minor Third 1.200]
- Rationale: [why this ratio]

### Hierarchy
| Level | Size | Weight | Line Height | Letter Spacing | Use |
|-------|------|--------|-------------|----------------|-----|
| Display | ... | ... | ... | ... | Hero, marketing |
| H1 | ... | ... | ... | ... | Page titles |
| H2 | ... | ... | ... | ... | Section heads |
| Body | ... | ... | ... | ... | Paragraphs |
| Small | ... | ... | ... | ... | Captions, labels |

### Fonts
- Primary: [font] - [rationale]
- Secondary: [font, if applicable]
- Mono: [font, if applicable]

### Implementation
```css
/* Ready-to-use CSS variables */
```
```

For typography audits:

```markdown
## Typography Audit

### Issues
| Element | Problem | Recommendation |
|---------|---------|----------------|
| ... | ... | ... |

### Quick Wins
- [Immediate improvement 1]
- [Immediate improvement 2]
```

## Core Principles

### Hierarchy & Structure
- Establish clear visual hierarchy through size, weight, and spacing
- Limit to 3-4 distinct heading levels in practice
- Use weight contrast (not just size) to differentiate levels
- Maintain consistent hierarchy patterns across the application

### Readability First
- Optimize for scanning: users read in F-patterns
- Left-align body text (centered only for short, formal text)
- Ensure sufficient contrast (4.5:1 minimum, 7:1 preferred)
- Test with real content, not lorem ipsum

### Restraint & Consistency
- Use 1-2 font families maximum (one serif, one sans-serif if pairing)
- Establish a type scale and stick to it
- Avoid decorative fonts for functional UI text
- Let whitespace do the work; resist the urge to fill

## Type Scales

### Modular Scales
Common ratios for harmonious sizing:
- **Minor Second** (1.067): Subtle, conservative
- **Major Second** (1.125): Gentle, professional
- **Minor Third** (1.200): Balanced, versatile
- **Major Third** (1.250): Bold, impactful
- **Perfect Fourth** (1.333): Strong hierarchy
- **Golden Ratio** (1.618): Dramatic, editorial

### Practical Scale (Minor Third, base 16px)
```
text-xs:   12px (0.75rem)
text-sm:   14px (0.875rem)
text-base: 16px (1rem)
text-lg:   18px (1.125rem)
text-xl:   20px (1.25rem)
text-2xl:  24px (1.5rem)
text-3xl:  30px (1.875rem)
text-4xl:  36px (2.25rem)
text-5xl:  48px (3rem)
```

### When to Deviate
- Marketing/hero sections can use larger jumps
- Dense data interfaces may need tighter scales
- Mobile often requires slightly larger base sizes

## Measure (Line Length)

### Optimal Ranges
- **Body text**: 45-75 characters (66 ideal)
- **Short-form**: 40-60 characters
- **Wide layouts**: Use columns or max-width constraints
- **Mobile**: Full width is acceptable due to narrow viewport

### Implementation
```css
/* Tailwind equivalents */
max-w-prose  /* ~65ch */
max-w-2xl    /* 672px, good for articles */
max-w-xl     /* 576px, compact content */
```

### Multi-Column Considerations
- Narrower columns = shorter measure acceptable
- Gutters should be at least 20px (1.25rem)
- Avoid orphaned words at column breaks

## Line Height (Leading)

### Guidelines by Context
- **Body text**: 1.5-1.7 (generous for readability)
- **Headings**: 1.1-1.3 (tighter, especially large sizes)
- **UI labels**: 1.2-1.4 (compact but legible)
- **Buttons**: 1.0-1.25 (single line, tight)

### Adjustments
- Increase line height for wider measure
- Decrease for larger type sizes
- Consider the x-height of the typeface
- Dark mode may benefit from slightly more leading

## Letter Spacing (Tracking)

### General Rules
- **Body text**: Default (0) or very slight increase
- **All caps**: Always add positive tracking (+0.05em to +0.1em)
- **Large headings**: Slight negative tracking (-0.01em to -0.02em)
- **Small text**: Slight positive tracking for legibility

### Tailwind Classes
```
tracking-tighter: -0.05em
tracking-tight:   -0.025em
tracking-normal:  0
tracking-wide:    0.025em
tracking-wider:   0.05em
tracking-widest:  0.1em
```

### All-Caps Text
- Always use `uppercase tracking-wide` or `tracking-wider`
- Keep short (1-3 words ideal)
- Common for labels, category tags, eyebrow text

## Font Selection

### System Font Stacks
Performant and native-feeling:
```css
/* Sans-serif (modern) */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

/* Serif */
font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;

/* Monospace */
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
```

### Web Font Considerations
- Limit to 2-3 weights per family (400, 500/600, 700)
- Use `font-display: swap` for performance
- Variable fonts reduce file size for multiple weights
- Self-host for privacy and reliability

### Pairing Principles
- Pair by contrast (serif + sans-serif)
- Match x-height for visual harmony
- Use one font for headings, one for body
- Ensure both have needed weights/styles

### Safe Recommendations
- **Sans-serif**: Inter, Source Sans Pro, Open Sans, Work Sans
- **Serif**: Source Serif Pro, Lora, Merriweather, Literata
- **Monospace**: JetBrains Mono, Fira Code, Source Code Pro

## Paragraph Spacing

### Between Paragraphs
- Use margin-bottom equal to line-height or slightly more
- Typically 1em to 1.5em between paragraphs
- First paragraph after heading: reduced or no top margin

### Between Sections
- 2-3x paragraph spacing between major sections
- Use consistent spacing tokens from design system
- Consider visual grouping via proximity

## Typographic Details

### Quotation Marks
- Use curly quotes (" " ' ') not straight quotes (" ')
- Proper apostrophes: it's, don't, '90s
- Consider the locale (French guillemets, German quotes)

### Dashes
- **Hyphen** (-): Word breaks, compound words
- **En dash** (–): Ranges (2020–2024), relationships (New York–London)
- **Em dash** (—): Parenthetical statements, emphasis

### Numbers
- Use tabular (monospace) figures in tables for alignment
- Use proportional figures in body text
- Consider old-style figures for editorial content

### Ellipsis
- Use proper ellipsis character (…) not three periods
- Add thin space before/after in formal typography

## Responsive Typography

### Fluid Type
Scale font sizes smoothly between breakpoints:
```css
/* clamp(min, preferred, max) */
font-size: clamp(1rem, 0.5rem + 1.5vw, 1.5rem);
```

### Breakpoint Adjustments
- Increase base size slightly on mobile (17-18px)
- Reduce heading scale on mobile
- Increase line height for small screens
- Reduce measure on tablets (prose can feel too wide)

### Touch Targets
- Minimum 44x44px for tappable text elements
- Generous padding around links in body text
- Avoid text-only targets without visual indication

## Dark Mode Typography

### Adjustments
- Reduce font weight slightly (medium instead of semibold)
- Increase letter spacing marginally
- Consider warmer white (#f5f5f5) over pure white (#fff)
- Increase line height by ~0.1 for perceived lightness

### Contrast Considerations
- Pure white on pure black is harsh; soften both
- Aim for 10:1 to 15:1 contrast in dark mode
- Test with actual users; perceived contrast differs

## Accessibility

### Font Size Minimums
- Body text: 16px minimum (don't go below)
- Secondary text: 14px minimum, 12px absolute floor
- Legal/caption: 12px with increased tracking

### User Preferences
- Respect `font-size` from browser settings
- Use relative units (rem) not fixed (px) for text
- Provide text scaling options for dense UIs

### Dyslexia Considerations
- Avoid justified text
- Prefer sans-serif with distinct letterforms
- Generous line height and paragraph spacing
- OpenDyslexic as optional font choice

## Common Mistakes

### Avoid
- All-caps body text or long headings
- Centered body paragraphs
- Line length over 80 characters
- Insufficient contrast for "aesthetic" reasons
- Mixing too many font families
- Decorative fonts for UI text
- Justified text on the web (causes rivers)
- Tiny gray text on white backgrounds

### Watch For
- Orphans and widows in prominent text
- Inconsistent heading hierarchy
- Missing font fallbacks
- Layout shift from web font loading
- Underlined text that isn't a link

Overview

This skill applies professional typography principles to create readable, hierarchical, and aesthetically refined interfaces. It delivers practical type systems, audits, and implementation guidance for web and product teams. Use it to set scales, choose fonts, optimize spacing, and solve readability or accessibility issues.

How this skill works

I inspect context (screen size, content density, and purpose) and recommend a compact type system: base size, modular ratio, hierarchy table, font choices, and CSS variables. For audits I list typographic issues with concrete recommendations and quick wins. Recommendations include measure, line-height, tracking, responsive rules, and accessibility constraints.

When to use it

  • Setting or refining a global type scale for a design system
  • Choosing font pairings and web-font loading strategy
  • Designing text-heavy layouts like articles, forms, or dashboards
  • Fixing readability, contrast, or line-length problems
  • Preparing responsive or dark-mode typography adjustments

Best practices

  • Establish a single type scale (3–5 levels of headings plus body and small) and stick to it
  • Limit families to 1–2 fonts, use variable fonts or 2–3 weights for performance
  • Use relative units (rem, ch) and font-display: swap to avoid layout shift
  • Aim for 45–75 characters per line for body text and 1.5–1.7 line-height for reading
  • Respect accessibility: 16px base minimum, 4.5:1 contrast minimum, and tappable text targets

Example use cases

  • Generate a ready-to-use type system with sizes, weights, and CSS variables for a product UI
  • Audit an app’s typography and produce a table of issues and prioritized fixes
  • Recommend font stack and web-font loading plan with weight-limits and fallbacks
  • Adjust headings, line-height, and measure for a responsive blog or marketing site
  • Tune dark-mode typography: weight, letter spacing, and color adjustments

FAQ

What modular scale ratio should I pick?

Choose Minor Third (1.2) for balanced UI work; use Major Third (1.25) for bolder hierarchy or Golden Ratio for editorial drama.

How do I fix long line lengths on wide layouts?

Constrain measure with max-width in characters (≈65ch) or use multi-column layouts with adequate gutters (≥20px). Increase line-height for wider measures.