# Typography

Two typefaces: Geist for interface text and Kbd hints, and JetBrains Mono for code, IDs and numbers in tables. Content text is 14px, and the scale is tuned around it.

## Typefaces

Geist is the interface font, including Kbd hints. JetBrains Mono is for code, IDs and numbers in tables.

| Use | Stack | Token |
| --- | --- | --- |
| Interface | Geist, ui-sans-serif, system-ui, sans-serif | `font-family-sans` |
| Code | 'JetBrains Mono', ui-monospace, monospace | `font-family-mono` |

The quick brown fox jumps over the lazy dog. 0123456789

Both are licensed under the SIL Open Font License 1.1. You can replace either one.

## Use your own font

Geist and JetBrains Mono are defaults, not requirements. Werewolf loads no font file, and each stack ends in `ui-sans-serif, system-ui, sans-serif` (code: `ui-monospace, monospace`). If a font is missing, the browser shows the system font and nothing breaks.

If your app already loads a font, yours wins. Point the token at it, in your own CSS after the Werewolf import. The page background, `font-sans` and `font-mono` all follow the token, so you change it once and no component needs an edit.

```css
:root {
  --font-family-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
  --font-family-mono: var(--font-fira-code), ui-monospace, monospace;
}
```

A font from `next/font` or any other provider shows up as a CSS variable. Put that variable first and keep the system keywords last.

```tsx
import { Inter } from "next/font/google"

const inter = Inter({ subsets: ["latin"], variable: "--font-inter" })

<html className={inter.variable}>
```

To use only the system font, leave the named font out.

```css
:root {
  --font-family-sans: ui-sans-serif, system-ui, sans-serif;
  --font-family-mono: ui-monospace, monospace;
}
```

A font with different metrics can move line breaks. The type roles and sizes stay the same.

## Type roles

A role sets size, weight and leading together. Use a role for headings and body text, never one role's size with another's weight.

Heading 1
Heading 2
Heading 3
Body text, 14px, for paragraphs and table cells.

| Role | Size | Weight | Leading |
| --- | --- | --- | --- |
| `heading-1` | 32px | 500 | 40px |
| `heading-2` | 24px | 500 | 32px |
| `heading-3` | 20px | 500 | 28px |
| `body` | 14px | 400 | 20px |

## UI sizes

The size/line-height pairs are 12/16, 14/20, 16/24, 18/28 and 20/28px. Each `text-*` size sets its paired `line-height-*` token. Body stays 14/20px.

| Token | Size | Line height | Use for |
| --- | --- | --- | --- |
| `font-size-xs` | 12px | 16px | Badges, tokens, captions and timestamps. |
| `font-size-sm` | 14px | 20px | Body copy, table cells, descriptions, helper and error text, and default (`md`) and `lg` controls. Also used in `sm` controls. |
| `font-size-md` | 16px | 24px | Headings and `xl` controls. |
| `font-size-lg` | 18px | 28px | Larger interface text. |
| `font-size-xl` | 20px | 28px | Larger headings. |
| `font-size-input` | 14px | 20px | Inputs, selects and textareas. 16px on touch screens, so iOS Safari does not zoom the page on focus. |

## Rules

Four rules from the design skill, each with one thing to write and one to avoid.

### Headings use sentence case

Checked by: judgment

Capitalize only the first word and proper nouns. Product and feature names keep the casing their owner uses. Title Case and `uppercase` make headings slower to read and louder than the content under them.

```tsx
// Do
<h2 className="text-heading-3">Billing history</h2>
// Avoid
<h2 className="text-heading-3">Billing History</h2>
<h2 className="text-heading-3 uppercase">Billing history</h2>
```

### Never change letter spacing

Checked by: judgment

No `tracking-*` classes and no `letter-spacing` in CSS. Geist and JetBrains Mono are already spaced for the sizes in the scale; tightening or loosening them is how generated UI starts to look generated.

```tsx
// Do
<span className="text-xs font-medium text-text-secondary">Last 30 days</span>
// Avoid
<span className="text-xs font-medium tracking-wide uppercase text-text-secondary">Last 30 days</span>
```

### No bold

Checked by: lint WW_CLASS_REMOVED, judgment

The scale has regular (400), medium (500) and semibold (600). There is no 700, and `font-bold` does nothing in a Werewolf project.

- Headings: the weight comes with the role (`text-heading-1` to `-3` set it). Don't add a weight class on top.
- Emphasis inside text, labels, button text: `font-medium`.
- `font-semibold` only when medium can't separate a label from medium text right next to it.

```tsx
// Do
<p className="text-body">Payment failed. <span className="font-medium">Update your card</span> to keep access.</p>
// Avoid
<p className="text-body">Payment failed. <b>Update your card</b> to keep access.</p>
```

### Inline code is 0.9em

Checked by: judgment

Mono text sitting inside a sans sentence looks bigger than the words around it at the same size. Use `code-inline`: it sets the mono family at `0.9em`, so it follows whatever size the sentence is.

```tsx
// Do
<p className="text-body">Run <code className="code-inline">npm run build</code> again.</p>
// Avoid
<p className="text-body">Run <code className="font-mono">npm run build</code> again.</p>
```
