Skip to content

Typography

Each type-* class sets the whole type stack at once. Read this for the roles, the sizes and the modifiers you chain onto them.

View source View as Markdown

Typography ships as type-* classes, one per role and size. Each class sets font-family, font-weight, font-size, line-height and text-transform in one declaration, and the type-surface-* roles set letter-spacing as well, so two elements carrying the same class render identically wherever they sit.

The surface and component split from the token tree runs through the classes as well, with surface type sized against prose and component type against controls.

Surface roles

Sized roles are type-surface-<role>-<size>, and the roles that only come in one size are type-surface-<role>.

type-surface-display-sm

Mirror sets the type

type-surface-title-md

Mirror sets the type

type-surface-subtitle-md

Mirror sets the type

type-surface-callout-md

Mirror sets the type

type-surface-body-md

Mirror sets the type

type-surface-body-sm

Mirror sets the type

type-surface-caption

Mirror sets the type

type-surface-footnote

Mirror sets the type

type-surface-code

Mirror sets the type

index.html
<h1 class="type-surface-title-md">Page title</h1>
<p class="type-surface-body-md">Body copy.</p>
<p class="type-surface-footnote">Footnote.</p>
RoleSizes
displaysm md lg xl
titlesm md lg xl
subtitlesm md lg xl
calloutsm md lg xl
bodysm md
captionnone
footnotenone
codenone

Component sizes

Component type is type-component-<size>, running from 5xs to 5xl and sized against controls rather than prose.

type-component-xs

Save changes

type-component-sm

Save changes

type-component-md

Save changes

type-component-lg

Save changes

type-component-xl

Save changes

modifier classes

Regular

Alt weight

Strong weight

1234567890

index.html
<span class="type-component-sm">Save changes</span>
<span class="type-component-md -strong">Save changes</span>
<span class="type-component-md -number">1234567890</span>

Modifier classes

Weight and family variations are chained onto the role class rather than replacing it.

ModifierApplies toEffect
-strongevery role except type-surface-codeThe role’s strong weight.
-alttype-component-*The alternate component weight.
-numbertype-component-*The numeric font family, for tabular digits.
-shorttype-surface-body-, type-surface-callout-The short line height, for headings set in body type.
<p class="type-surface-body-sm -strong">A strong lead sentence.</p>

A modifier only changes the one property it names, so -strong resolves against whichever role it is attached to: type-surface-title-md -strong takes the title role’s strong weight and type-surface-body-sm -strong takes the body role’s, and a theme is free to set the two apart.

Limitations

A type-* class sets the whole stack at once, and there is no font-*, text-<size>, leading-* or tracking-* escape hatch into the token values. Mixing a title’s size with a body’s line height is the drift the roles exist to prevent. The cost is that a real exception has to be written as plain CSS, which we think is the right place for it to be visible.

Tailwind’s own text-left, truncate and friends are untouched, since we only own the type roles.