Typography
The text roles YolkUI components use. One class sets the size, line height, weight and tracking, and each role points at a step of Tailwind's type scale.
Text roles
A component writes text-label, not text-sm font-medium. Each role is a Tailwind v4 theme variable that carries its own line height, weight and tracking, so one class sets all four. Size is the font size over the line height, and the roles with an empty last column are there for your own pages.
| Role | Size | Weight, tracking | Used by |
|---|---|---|---|
text-display | 48/52px | 700, tight | |
text-h1 | 36/40px | 700, tight | |
text-h2 | 30/36px | 600, tight | |
text-h3 | 24/32px | 600 | |
text-h4 | 20/28px | 600 | Avatar initials at 2xl |
text-h5 | 18/28px | 600 | |
text-h6 | 16/24px | 600 | Card, Dialog and Alert Dialog titles |
text-body-lg | 18/28px | 400 | |
text-body | 16/24px | 400 | Text in fields and menu rows below the md breakpoint, so iOS never zooms in |
text-body-sm | 14/20px | 400 | Most component text: menu rows, descriptions, Accordion, Alert, Toast, Calendar |
text-label | 14/20px | 500 | Button, Label, Tabs, Toggle, Segmented Control, Accordion triggers |
text-label-sm | 12/16px | 500 | Button, Tabs, Toggle and Segmented Control at their smallest size |
text-caption | 12/16px | 400 | Badge, Tooltip, Field descriptions and errors, menu group labels and shortcuts, Calendar weekdays |
text-overline | 12/16px | 600, 0.06em | |
text-overline-mono | 12/16px | 400, 0.06em, mono capitals | |
text-code | 14/20px | 400 |
Use a role
Write the role as one class, and add a color beside it. The role sets the size, the line height, the weight and the tracking; the color stays your choice.
<h2 className="text-h3">Billing</h2>
<p className="text-body-sm text-muted-foreground">Your plan renews on May 1.</p>
<span className="text-caption text-muted-foreground">Updated 2 minutes ago</span>Change or add a role
Set the role again in an @theme inline block after the theme's. Here every Card, Dialog and Alert Dialog title grows to 18px, and a new text-eyebrow role becomes a class you can use anywhere.
@theme inline {
--text-h6: var(--text-lg);
--text-h6--line-height: var(--text-lg--line-height);
--text-eyebrow: var(--text-xs);
--text-eyebrow--line-height: var(--text-xs--line-height);
--text-eyebrow--font-weight: var(--font-weight-medium);
--text-eyebrow--letter-spacing: var(--tracking-wide);
}Fonts
The roles set text in font-sans and code in font-mono, so they use your fonts once Theming points the two at them. The sizes behind the roles are Tailwind's type scale, unchanged.