Typography

Text sizes, weights and font families used across GitHub.

Looking for Primer's color design tokens? See the typography primitives page.

Typographic styles

Overview

Typography design tokens use rem units for a more accessible browser zoom experience. Additionally, line height values are unitless and vary per style, making them align to the 4px grid. Each style is opinionated, as reflected in the “shorthand” tokens which control size, family, weight, and line-height with a single font CSS declaration.

Best practices

Hierarchy

When establishing hierarchy for GitHub products, designers should remember that we stress efficient, clean reading experiences for our users. Refrain from utilizing color as a primary method of emphasis.

Readability

  • Line height—Utilize line-height tokens for proper alignment.

  • Line length—It's considered a good practice to keep lines around 80 characters or less—W3 Page Structure Guidelines. Cases vary depending on the situation, but this serves as a general rule of thumb for designing layouts.

  • Type alignment—Our content is typically left-aligned and ragged right. Be sensible in deviating from this standard, as justifying, centering, and right-aligning text is atypical of GitHub products.

DoA css class targeting h2 with font-weight set to the variable --test-subtitle-weight.

Use weight CSS variables to set font-weight

Don’tA css class targeting h2 with font-weight set to 700.

Don't use arbitrary weight number values for font-weight

DoA screenshot of a repository settings page. First is an H1 that is labelled Repository settings followed by an h2 labelled general.

Use semantic title markup combined with styles

Don’tAn html snippet with a main HTMLElement that contains an h2 HTMLElement than an h1 HTMLElement.

Don’t adjust semantic heading tag order to achieve a specific visual design