Typography

Comic Sans not included. Size text by what it does, and change a whole role in one place.

Demo

Release 2.4 · 3 min read

Faster sync for large projects

Changes now stream in as they happen, so opening a project with thousands of files no longer waits for a full download.

Text comes in five roles, each in three sizes: sm, md and lg. A role is one utility that sets size, line height and weight together, so text-label-lg is all a button label needs. leading-* and font-* still override one part of it.

RoleFor
displayThe largest text on a screen: short hero lines and numerals.
headlinePage and section titles.
titleTitles inside a surface: a card, a dialog, a list group.
bodyRunning text.
labelText inside controls: buttons, tabs, chips, form labels.

Usage

Pick the role by what the text does, not by how big it should be. Components do the same: a md or lg button labels with label-lg, so changing that one role restyles every one of them.

<template>
  <p class="text-label-md text-muted-foreground">Release 2.4</p>
  <h3 class="text-headline-sm">Faster sync for large projects</h3>
  <p class="text-body-md">Changes now stream in as they happen.</p>
</template>

The utilities come with the tokens item. Keep Kappa UI's cn(), or it drops them next to a text colour: see Installation.

Customising

Each role reads --typescale-<role>-size, -line-height and -weight from :root, so you change a role in one place:

:root {
  --typescale-label-lg-size: 0.9375rem;
  --typescale-label-lg-weight: 600;
}

They're plain variables, so they can change with the screen too. Step the large roles by window size, and leave body and label alone:

@media (width < 600px) {
  :root {
    --typescale-display-lg-size: 2.8125rem;
    --typescale-display-lg-line-height: 3.25rem;
  }
}

There's no letter-spacing: text keeps the spacing its font was designed with.

Bring any font you like, as long as it has weight 500: the label roles, title-sm and title-md use it. Without it, the browser falls back to regular. Segoe UI on Windows 10 is one such font.

Scale

display lg text-display-lg
display md text-display-md
display sm text-display-sm
headline lg text-headline-lg
headline md text-headline-md
headline sm text-headline-sm
title lg text-title-lg
title md text-title-md
title sm text-title-sm
body lg text-body-lg
body md text-body-md
body sm text-body-sm
label lg text-label-lg
label md text-label-md
label sm text-label-sm

Next

  • Motion: easing curves and durations.
  • Sizing: the scale behind every size prop.