# Text

Text treatments that set font size, line height and letter spacing together.

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

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

## Classes

| Class | Property | Declarations |
| --- | --- | --- |
| [`text-<name>`](/reference/tokens/families#family-text) | `font-size, line-height, letter-spacing` | `font-size: var(--text-<name>);` `line-height: var(--text-<name>--line-height, normal);` `letter-spacing: var(--text-<name>--letter-spacing, normal);` |

A primary `--text-<name>` token creates the class; its `--line-height` and `--letter-spacing` companions are optional and fall back to `normal`. Family, weight and color stay separate classes.

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

## Values

Each row shows the three values read by one class. Preset sizes reference the matching font-size token; the table resolves that reference for reading. All preset treatments include both companions.

| Class | Variable | Size | Line height | Letter spacing |
| --- | --- | --- | --- | --- |
| `text-3xs` | `--text-3xs` | `var(--font-size-3xs)` | `1.5` | `0` |
| `text-2xs` | `--text-2xs` | `var(--font-size-2xs)` | `1.5` | `0` |
| `text-xs` | `--text-xs` | `var(--font-size-xs)` | `1.5` | `0` |
| `text-sm` | `--text-sm` | `var(--font-size-sm)` | `1.5` | `0` |
| `text-md` | `--text-md` | `var(--font-size-md)` | `1.6` | `0` |
| `text-lg` | `--text-lg` | `var(--font-size-lg)` | `1.5` | `0` |
| `text-xl` | `--text-xl` | `var(--font-size-xl)` | `1.4` | `-.01em` |
| `text-2xl` | `--text-2xl` | `var(--font-size-2xl)` | `1.35` | `-.015em` |
| `text-3xl` | `--text-3xl` | `var(--font-size-3xl)` | `1.25` | `-.02em` |
| `text-4xl` | `--text-4xl` | `var(--font-size-4xl)` | `1.2` | `-.025em` |
| `text-5xl` | `--text-5xl` | `var(--font-size-5xl)` | `1.15` | `-.03em` |
| `text-6xl` | `--text-6xl` | `var(--font-size-6xl)` | `1.1` | `-.035em` |
| `text-7xl` | `--text-7xl` | `var(--font-size-7xl)` | `1.05` | `-.04em` |
| `text-8xl` | `--text-8xl` | `var(--font-size-8xl)` | `1.05` | `-.04em` |
| `text-9xl` | `--text-9xl` | `var(--font-size-9xl)` | `1` | `-.045em` |
| `text-10xl` | `--text-10xl` | `var(--font-size-10xl)` | `1` | `-.05em` |

<a id="primary-and-companions"></a>

## One primary token, three declarations

`--text-card` registers `text-card`. The class always emits font size, line height and letter spacing. If `--text-card--line-height` or `--text-card--letter-spacing` is absent, its declaration uses `normal`; it does not preserve an inherited value.

**A text treatment always writes three properties**

Only the primary --text-card token is defined here. Both companion declarations still exist and use normal, replacing any inherited line height or letter spacing.

- The custom theme defines --text-card as 1.5rem and defines neither companion.
- text-card emits font-size: var(--text-card), line-height: var(--text-card--line-height, normal) and letter-spacing: var(--text-card--letter-spacing, normal).
- All three solid branches represent emitted declarations. The absent companions use their normal fallback rather than inheriting another line height or letter spacing.
- A companion on its own does not register text-card. Family, weight and color are outside this recipe.

A companion alone does not register a treatment. Add the primary size token even when the only value you want to customize is its line height or letter spacing.

A companion is a value used by this recipe, not another class name. Independent adjustments use `font-<size>`, `leading-<name>` or `tracking-<name>`. Under the same conditions, these single-property utilities sort after the text recipe and can override its corresponding declaration; their order in the class attribute does not decide the result.

The recipe does not load a font, select its family or weight, add margins or decide the width of a paragraph. Typography Guide owns choosing and combining treatments into a hierarchy.

See [Font](/reference/tokens/font) and [Leading](/reference/tokens/leading) and [Tracking](/reference/tokens/tracking) and [generated rule order](/reference/rules/layers).

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

## Usage

Apply one treatment to a paragraph; its family, weight and color remain independent.

```html
<p class="… text-lg">A paragraph keeps its size,…</p>
```

```css disclosure=generated-css
@layer theme{:root,:host{--font-size-lg:1.125rem;--text-lg:var(--font-size-lg);--text-lg--line-height:1.5;--text-lg--letter-spacing:0}}@layer utilities{.text-lg{font-size:var(--text-lg);line-height:var(--text-lg--line-height, normal);letter-spacing:var(--text-lg--letter-spacing, normal)}}
```

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

## Customize

Add a treatment with its companions: `--text-display` creates `text-display`.

```css
@theme {
  --text-display: 3.5rem;
  --text-display--line-height: 1.1;
  --text-display--letter-spacing: -.03em;
}
```

```css disclosure=generated-css
@layer theme{:root,:host{--text-display:3.5rem;--text-display--line-height:1.1;--text-display--letter-spacing:-.03em}}@layer utilities{.text-display{font-size:var(--text-display);line-height:var(--text-display--line-height, normal);letter-spacing:var(--text-display--letter-spacing, normal)}}
```

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

## Related reference

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