Typography
Comic Sans not included. Size text by what it does, and change a whole role in one place.
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.
| Role | For |
|---|---|
display | The largest text on a screen: short hero lines and numerals. |
headline | Page and section titles. |
title | Titles inside a surface: a card, a dialog, a list group. |
body | Running text. |
label | Text 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.