Tailwind CSS Handbook v4.3

Text Styling

Colour, alignment, decoration, transform, truncation, wrapping and text shadows — everything you apply to text after choosing a font.

Once the type scale is settled, these are the utilities you use every day.

Colour#

HTML
<p class="text-gray-900 dark:text-gray-100">Body</p>
<p class="text-gray-500">Muted</p>
<a class="text-indigo-600 hover:text-indigo-500">Link</a>
<p class="text-red-600/80">Error at 80% opacity</p>

Full palette and the opacity modifier are covered in Colors.

Alignment#

UtilityCSS
text-left text-center text-rightPhysical alignment
text-justifyJustified — use sparingly on the web
text-start / text-endLogical, flips in RTL

Vertical alignment of inline content uses align-*: align-baseline, align-middle, align-top, align-bottom, align-text-top, align-text-bottom, align-sub, align-super.

Decoration#

UtilityEffect
underline overline line-through no-underlineLine type
decoration-solid decoration-dashed decoration-dotted decoration-wavy decoration-doubleStyle
decoration-2 decoration-4Thickness
decoration-indigo-500Colour
underline-offset-4Distance from the baseline
Loading preview…

Transform and style#

UtilityEffect
uppercase lowercase capitalize normal-casetext-transform
italic / not-italicfont-style

Truncation and clamping#

UtilityBehaviour
truncateOne line, ellipsis — sets overflow-hidden text-ellipsis whitespace-nowrap
text-ellipsis / text-clipOverflow behaviour on its own
line-clamp-3Exactly three lines, then an ellipsis
line-clamp-noneRemove clamping
Loading preview…

Wrapping and breaking#

UtilityBehaviour
text-wrapDefault wrapping
text-nowrapNever wrap
text-balanceBalance line lengths — for headings
text-prettyAvoid orphans — for paragraphs
wrap-break-wordBreak long words when needed v4.1
wrap-anywhereBreak anywhere, including inside flex items v4.1
break-allBreak between any two characters
break-keepDo not break CJK text
whitespace-pre / whitespace-pre-wrap / whitespace-pre-linePreserve whitespace
Loading preview…

Text shadow#

v4.1

UtilitySize
text-shadow-2xs text-shadow-xs text-shadow-sm text-shadow-md text-shadow-lgPresets
text-shadow-indigo-500Colour
text-shadow-lg/30Colour with opacity
text-shadow-noneRemove
Loading preview…

Useful for text over photography, where a shadow keeps it readable regardless of the background.

Lists#

UtilityEffect
list-disc list-decimal list-noneMarker type
list-inside / list-outsideMarker position
marker:text-indigo-500Style the markers
HTML
<ul class="list-disc space-y-1 pl-5 marker:text-indigo-500">
  <li>Styled markers</li>
</ul>

Other useful utilities#

UtilityPurpose
indent-8First-line indent
align-middleVertical alignment of inline boxes
selection:bg-indigo-100Style highlighted text
caret-indigo-600Text cursor colour
hyphens-autoAutomatic hyphenation (needs lang)
content-['—']Pseudo-element content
sr-onlyVisually hidden, still announced

Common patterns#

Article heading and lede#

HTML
<header class="mx-auto max-w-3xl">
  <p class="text-sm font-semibold tracking-wide text-indigo-600 uppercase">Engineering</p>
  <h1 class="mt-2 text-4xl font-bold tracking-tight text-balance text-gray-900 sm:text-5xl">
    Shipping a design system without a component library
  </h1>
  <p class="mt-4 text-lg leading-relaxed text-pretty text-gray-600">
    How we replaced 40,000 lines of CSS with a token layer and a handful of primitives.
  </p>
</header>

Truncated list row#

HTML
<li class="flex min-w-0 items-center gap-3">
  <span class="size-2 shrink-0 rounded-full bg-emerald-500"></span>
  <span class="min-w-0 flex-1 truncate">A long item title that will be cut off cleanly</span>
  <time class="shrink-0 text-xs text-gray-500">2h</time>
</li>

Code and keyboard hints#

HTML
<p class="text-sm text-gray-700">
  Press <kbd class="rounded border border-gray-300 bg-gray-50 px-1.5 py-0.5 font-mono text-xs">⌘K</kbd>
  to open <code class="rounded bg-gray-100 px-1 py-0.5 font-mono text-xs">search</code>.
</p>

Common mistakes#

  • truncate on a flex child without min-w-0. Nothing happens.
  • Removing link underlines. Fails colour-blind users.
  • text-justify for web body copy. Without hyphenation it creates rivers of whitespace.
  • text-center on long paragraphs. Centred text has no consistent left edge, which slows reading.
  • line-clamp-* on content the user needs. It hides information with no affordance to reveal it; pair it with a "show more" control.
  • Using text-white on a light gradient without a shadow. Contrast fails in the light regions.