# Font

Font families, sizes and weights, all written as font-*.

- ID: tokens/font
- Type: tokens
- Canonical: /reference/tokens/font
- Version: 2.1.8
- Source revision: 09fc2350ea80ed137ba7ca62c8e5926744b5a5dc (revision)
- Source: packages/preset/src/theme.css
- Content digest: e7914cfd9665fe45531c8ef4801b5c28614f52f2c32152e2855f3532dcba8997
- Semantic digest: 83962260d6d56817dd052d2beebf7999a75804215dac050c47b26353145c099a
- Language: en

<a id="consumers"></a>

## Classes

| Class | Property | Declarations |
| --- | --- | --- |
| [`font-<family>`](/reference/tokens/families#family-font) | `font-family` | `font-family: var(--font-family-<family>)` |
| [`font-<size>`](/reference/tokens/families#family-font) | `font-size` | `font-size: var(--font-size-<size>)` |
| [`font-<weight>`](/reference/tokens/families#family-font) | `font-weight` | `font-weight: var(--font-weight-<weight>)` |

The three namespaces share the `font-` prefix, so a name must be unique among them. A name defined in more than one reports `AMBIGUOUS_TOKEN` and generates no CSS.

<a id="values"></a>

## Values

Families are ordered fallback lists, sizes are rem lengths and weights are numeric requests. Pixel equivalents assume a 16px root font size. The rendered face and available weights depend on the fonts loaded by the page.

<a id="font-family"></a>

### Family

| Class | Variable | Value |
| --- | --- | --- |
| `font-sans` | `--font-family-sans` | `var(--font-sans, ui-sans-serif), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"` |
| `font-mono` | `--font-family-mono` | `var(--font-mono, ui-monospace), SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace` |
| `font-serif` | `--font-family-serif` | `var(--font-serif, ui-serif), Georgia, Cambria, "Times New Roman", Times, serif` |

<a id="font-size"></a>

### Size

| Class | Variable | Value |
| --- | --- | --- |
| `font-3xs` | `--font-size-3xs` | `.5rem` |
| `font-2xs` | `--font-size-2xs` | `.625rem` |
| `font-xs` | `--font-size-xs` | `.75rem` |
| `font-sm` | `--font-size-sm` | `.875rem` |
| `font-md` | `--font-size-md` | `1rem` |
| `font-lg` | `--font-size-lg` | `1.125rem` |
| `font-xl` | `--font-size-xl` | `1.25rem` |
| `font-2xl` | `--font-size-2xl` | `1.5rem` |
| `font-3xl` | `--font-size-3xl` | `2rem` |
| `font-4xl` | `--font-size-4xl` | `2.25rem` |
| `font-5xl` | `--font-size-5xl` | `2.5rem` |
| `font-6xl` | `--font-size-6xl` | `3rem` |
| `font-7xl` | `--font-size-7xl` | `3.75rem` |
| `font-8xl` | `--font-size-8xl` | `4.5rem` |
| `font-9xl` | `--font-size-9xl` | `6rem` |
| `font-10xl` | `--font-size-10xl` | `8rem` |

<a id="font-weight"></a>

### Weight

| Class | Variable | Value |
| --- | --- | --- |
| `font-thin` | `--font-weight-thin` | `100` |
| `font-extralight` | `--font-weight-extralight` | `200` |
| `font-light` | `--font-weight-light` | `300` |
| `font-regular` | `--font-weight-regular` | `400` |
| `font-medium` | `--font-weight-medium` | `500` |
| `font-semibold` | `--font-weight-semibold` | `600` |
| `font-bold` | `--font-weight-bold` | `700` |
| `font-extrabold` | `--font-weight-extrabold` | `800` |
| `font-heavy` | `--font-weight-heavy` | `900` |

<a id="independent-properties"></a>

## One prefix, independent properties

`font-serif`, `font-4xl` and `font-semibold` write `font-family`, `font-size` and `font-weight` respectively. They can be combined because they set different properties; none is a complete type treatment.

**The font prefix can change three independent properties**

Every row starts with font-sans, font-2xl and font-regular. The result replaces only the class for the named property. The available fonts determine the rendered faces.

- The baseline text uses the sans family, 1.5rem size and weight 400, with a 16px root font size.
- The font-serif row changes only font-family. The font-4xl row changes only font-size, to 2.25rem. The font-semibold row changes only font-weight, to 600.
- Each result uses the same words. A common unitless line-height of 1.5 keeps the samples readable; these font classes do not set line-height.
- The samples render real preset CSS with available system fonts. They do not imply that a family class downloads a font file.

A size class leaves line height and letter spacing to their own declarations or inheritance. Use `text-<name>` when all three metrics should come from one treatment. Family and weight remain separate in either form.

A family token names fonts; it does not download them. The preset sans, mono and serif stacks begin with the optional `--font-sans`, `--font-mono` and `--font-serif` hooks. The Typography guide owns loading fonts and choosing a site-wide stack.

Keep custom keys distinct across the three namespaces. If both `--font-family-brand` and `--font-size-brand` exist, `font-brand` is ambiguous. An explicit native declaration such as `(font-size:var(--font-size-brand))` names the intended property and variable.

See [Text treatments](/reference/tokens/text) and [namespace resolution](/reference/rules/modes#namespace-resolution) and [native font selection](https://www.w3.org/TR/css-fonts-4/#font-family-prop).

<a id="usage"></a>

## Usage

Set a heading in a larger size and medium weight, and a code sample in the mono family.

```html
<h3 class="… font-2xl font-medium">Release notes</h3>
<p class="… font-sm">Install the new version with <code class="… font-mono font-xs">npm i @master/css</code>.</p>
```

```css disclosure=generated-css
@layer theme{:root,:host{--font-family-mono:var(--font-mono, ui-monospace), SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--font-weight-medium:500;--font-size-xs:.75rem;--font-size-sm:.875rem;--font-size-2xl:1.5rem}}@layer utilities{.font-mono{font-family:var(--font-family-mono)}.font-2xl{font-size:var(--font-size-2xl)}.font-sm{font-size:var(--font-size-sm)}.font-xs{font-size:var(--font-size-xs)}.font-medium{font-weight:var(--font-weight-medium)}}
```

<a id="customize"></a>

## Customize

Each namespace takes its own tokens: `--font-family-display` creates `font-display`, and `--font-size-hero` creates `font-hero`.

```css
@theme {
  --font-family-display: "Inter Display", var(--font-family-sans);
  --font-size-hero: 4rem;
}
```

```css disclosure=generated-css
@layer theme{:root,:host{--font-family-sans:var(--font-sans, ui-sans-serif), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"}:root,:host{--font-family-display:"Inter Display", var(--font-family-sans);--font-size-hero:4rem}}@layer utilities{.font-display{font-family:var(--font-family-display)}.font-hero{font-size:var(--font-size-hero)}}
```

See [theme directives](/reference/directives/theme) and [Typography](/guide/typography).

## Related reference

- [rules/modes](/reference/rules/modes.md)
- [directives/theme](/reference/directives/theme.md)
