Sub topic 9
Line height (leading) and letter spacing (tracking)
This chapter assumes you know the font size utilities (text-sm, text-3xl) and how a class name maps to one CSS declaration. It covers the two utility families that fine-tune how text is spaced: leading-* for line height and tracking-* for letter spacing.
Line height with leading
Line height is the height of each line box. Tailwind calls these utilities "leading". They set the CSS line-height property.
There are two kinds of values:
- Relative values, which multiply the element's font size:
leading-none(1),leading-tight(1.25),leading-snug(1.375),leading-normal(1.5),leading-relaxed(1.625), andleading-loose(2). - Fixed values from the spacing scale:
leading-6is 1.5rem andleading-10is 2.5rem. These do not change when the font size changes.
<h1 class="text-3xl font-bold leading-tight tracking-tight">Spacing and type</h1>
<p class="text-base leading-relaxed text-gray-600">Body copy with extra room between lines.</p>Use relative values for most text. A relative value keeps its proportion if you later change text-base to text-lg. Use a fixed value when you need lines to align to a grid, or when you want the same line height across different font sizes.
Setting size and line height in one class
Every text-* size utility sets a default line height too. The slash syntax overrides that default in the same class:
<p class="text-base/7 text-gray-600">Body copy with a 1.75 line height.</p>text-base/7 sets font-size: 1rem and line-height: 1.75rem, because the number after the slash comes from the spacing scale. This form needs Tailwind v3.3 or later. If you write both text-base/7 and leading-6 on one element, the two conflict. Use only one of them.
Choosing a line height
Large headings look loose with the default line height, so tighten them (leading-tight or leading-snug). Long paragraphs need more room than headings, so leading-normal to leading-relaxed works well. Very tight values such as leading-none suit single-line text like badges or large display numbers. They can cause lines to overlap when text wraps.
Letter spacing with tracking
Tailwind calls letter spacing "tracking". The utilities set letter-spacing in em units, so the spacing scales with the font size.
| Class | Letter spacing |
|---|---|
| `tracking-tighter` | -0.05em |
| `tracking-tight` | -0.025em |
| `tracking-normal` | 0em |
| `tracking-wide` | 0.025em |
| `tracking-wider` | 0.05em |
| `tracking-widest` | 0.1em |
Large headings often look better with tracking-tight, because big letters appear more widely spaced. Small uppercase labels often look better with tracking-wide or tracking-wider, because capitals need extra room.
<p class="text-xs font-semibold uppercase tracking-wider text-gray-500">Category</p>
<h2 class="text-4xl font-bold leading-tight tracking-tight">A tighter heading</h2>Common errors
- Putting
leading-*on a parent and expecting a child with its owntext-*size to follow it. Thetext-*size utilities set a line height, so the child gets its own default. Set the leading on the element that holds the text. - Using a fixed value like
leading-6on text that later grows. The line height stays the same and lines may collide. Prefer relative values ortext-base/7style pairs. - Using
tracking-*to fix a font that looks wrong. Tracking changes every pair of letters equally, so apply small steps.
Exercise
A label needs a 12px font size, all capitals, slightly wider letter spacing, and a line height of 1rem. Write the class list using the slash syntax for size and line height.
Show answer
text-xs/4 uppercase tracking-wide. The text-xs class sets 0.75rem (12px), and /4 sets the line height to 1rem from the spacing scale. Use tracking-wider if you want a bigger gap.