Typography

Raw
GuidancelatestcurrentRetrieved 2026-05-12

Primer — Typography

Overview

Primer's typography system uses rem units for accessibility — this allows browser zoom to scale text correctly. Line height values are unitless and aligned to a 4px grid. Each typographic style uses "shorthand" tokens that control size, family, weight, and line-height simultaneously via a single font CSS declaration.

Note: The typographic styles described here represent the functional token layer. The Storybook component previews on the primer.style doc site show rendered output — actual token values are sourced from primer/primitives.


Font families

Primer uses system font stacks — no custom typeface is loaded. This prioritizes performance and ensures text renders with the OS-native font, which users are already accustomed to.

TokenStackUse
fontStack-system-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serifAll UI text
fontStack-monospaceui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospaceCode, terminal output, technical values
fontStack-sansSerifDisplaySystem sans-serif optimized for large display sizesDisplay headings (if distinct from system)

Type scale

Base sizes defined in the base.text.size token set (from primer/primitives):

TokenrempxDescription
base.text.size.xs0.75rem12pxCaptions, compact UI labels
base.text.size.sm0.875rem14pxDefault body text, most UI content
base.text.size.md1rem16pxLarge body text, small titles
base.text.size.lg1.25rem20pxMedium titles, subtitles
base.text.size.xl2rem32pxLarge page headings
base.text.size.2xl2.5rem40pxDisplay text, hero sections

Font weights

TokenValueUse
base.text.weight.light300Rarely used; very large display text only
base.text.weight.normal400Body text, default
base.text.weight.medium500Slightly emphasized labels and metadata
base.text.weight.semibold600Headings, strong emphasis

Always use weight CSS variables (var(--base-text-weight-semibold)) rather than hardcoded numeric values.


Functional typographic styles

Shorthand styles covering heading, body, and code categories. Each shorthand token sets size, weight, line-height, and font-family together.

Headings

StyleSizeWeightUse
Display2.5rem (40px)SemiboldHero sections, large page titles
Title Large2rem (32px)SemiboldTop-level page headings
Title Medium1.25rem (20px)SemiboldSection headings
Title Small1rem (16px)SemiboldSub-section headings, card titles
Subtitle1rem (16px)MediumSupporting text below a title

Body

StyleSizeWeightUse
Body Large1rem (16px)NormalIntroductory body text, descriptions
Body Medium0.875rem (14px)NormalDefault UI body text
Body Small0.75rem (12px)NormalCompact contexts, helper text
Caption0.75rem (12px)NormalLabels below images, auxiliary context

Code

StyleUse
Code BlockMulti-line code samples; monospace font stack, md size
Inline CodeInline technical terms within prose; monospace, slightly smaller

Line heights

TokenValueUse
base.text.lineHeight.tight1.25Single-line labels, badges, buttons — not multi-line body text
base.text.lineHeight.normal1.5Standard body text
base.text.lineHeight.relaxed1.75Long-form content, documentation prose

Line heights are unitless and vary per style, aligning to the 4px grid.


Best practices

Hierarchy

Use weight to establish content hierarchy. Avoid relying on color alone as the primary method of emphasis.

Readability

  • Line length: Aim for ~80 characters per line (W3C guideline). Adjust for context.
  • Alignment: Default to left-aligned, ragged-right. Justify, center, or right-align only when intentional and appropriate.
  • Font weight: Use weight CSS variables to set font-weight — do not use arbitrary numeric values.
  • Letter spacing: Do not adjust letter-spacing. There are rare exceptions, but this is a strict default.
  • Heading order: Do not adjust semantic heading tag order (h1–h6) purely for visual design. Use CSS classes to achieve the desired visual style while maintaining semantic hierarchy.

Related components

  • Heading
  • PageHeader
  • Text