Menu

Tailwind CSS Typography

Typography utilities in Tailwind CSS provide control over text presentation, ensuring readability, accessibility, and aesthetic appeal across different screen sizes. These utilities cover font families, sizes, styles, weight variations, line heights, text alignment, and advanced text effects. By leveraging Tailwind’s utility-first approach, developers can apply precise typography styles without writing custom CSS.

Additionally, Tailwind offers list styling, text decoration, and vertical alignment utilities, ensuring fine-grained control over text-related elements. Combined with responsive variants, these utilities help create dynamic and well-structured typography.

UtilityDescriptionExample
Font FamilyApplies a specified font family to text elements.<p className="font-sans">Sample text</p>
Font SizeControls text size from various extra-small to extra-large.<p className="text-lg">Sample text</p>
Font SmoothingToggles text rendering for sharper or smoother results.<p className="antialiased">Sample text</p>
Font StyleDefines normal or italic text style for elements.<p className="italic">Sample text</p>
Font WeightSpecifies thickness of text, from light to bold.<p className="font-bold">Sample text</p>
Font Variant NumericProvides specialized numeric settings like tabular-nums, lining-nums, etc.<p className="tabular-nums">1234</p>
Letter SpacingAdjusts spacing between individual letters for precise typography.<p className="tracking-wide">Sample text</p>
Line ClampLimits text lines before truncating with an ellipsis.<p className="line-clamp-3">Sample text</p>
Line HeightSpecifies vertical spacing between lines of text content.<p className="leading-relaxed">Sample text</p>
List Style ImageSets custom image for list item markers in lists.

<ul className="list-image-[url(/path/to/image.png)]"> <li>Item</li> </ul>

List Style PositionDetermines whether list markers appear inside or outside.<ul className="list-inside"><li>Item</li></ul>
List Style TypeDefines the marker type for list item bullets.<ul className="list-disc"><li>Item</li></ul>
Text AlignAligns text content to left, center, right, or justify.<p className="text-center">Sample text</p>
Text ColorApplies a specific color to text elements dynamically.<p className="text-red-500">Sample text</p>
Text DecorationAdds underlines, overlines, or line-through to text elements.<p className="underline">Sample text</p>
Text Decoration ColorSets color of text decoration, like underline or line-through.<p className="decoration-blue-500 underline">Sample text</p>
Text Decoration StyleControls decoration style, e.g., solid, dotted, or dashed.<p className="decoration-dotted underline">Sample text</p>
Text Decoration ThicknessDetermines the thickness of an underline or line-through.<p className="underline decoration-4">Sample text</p>
Text Underline OffsetOffsets underline distance from the text baseline visually.<p className="underline underline-offset-4">Sample text</p>
Text TransformTransforms text case, like uppercase, lowercase, or capitalize.<p className="uppercase">Sample text</p>
Text OverflowHandles clipped or ellipsed text exceeding container boundaries.<p className="truncate">Sample text</p>
Text WrapControls whether text wraps or overflows container boundaries.<p className="text-wrap">Sample text</p>
Text IndentSets indentation for the first line of text blocks.<p className="indent-8">Sample text</p>
Vertical AlignVertically aligns inline or table-cell elements within container.<span className="align-middle">Sample text</span>
WhitespaceControls handling of whitespace and line breaks in text.<p className="whitespace-pre-line">Sample text</p>
Word BreakSpecifies how words should break or wrap within text.<p className="break-all">Sample text</p>
HyphensEnables automatic hyphenation of words across line breaks.<p className="hyphens-auto">Sample text</p>
ContentInserts generated content before or after an element.

<div className="before:content-['Hello']"> Sample text </div>

Best Practices

Use font-family for Consistent Branding

Tailwind provides font-sans, font-serif, and font-mono utilities to control typography across elements. These ensure that text maintains a consistent look and feel aligned with brand guidelines. For custom fonts, use @theme, @import, and @font-face directives to include additional typefaces and use them in your projects.

Define Readable Text Sizes

Tailwind’s text-* utilities (text-xs to text-9xl) provide predefined font sizes that scale responsively. Use a default text-* utility to ensure consistent readability across elements. For accessibility, apply sm:text-lg or lg:text-xl to improve legibility on larger screens while maintaining a proportional scale across breakpoints.

Enhance Clarity with font-smoothing

The antialiased and subpixel-antialiased utilities improve font rendering. While antialiased softens text appearance, subpixel-antialiased maintains sharpness for improved contrast. Using antialiased is recommended for most UI designs to ensure a visually smoother experience, particularly for body text.

Control Text Style and Weight

Tailwind’s italic, not-italic, and font-* weight utilities allow for fine-grained typography control. These utilities ensure consistent text emphasis while maintaining visual balance. To improve accessibility, avoid excessive use of italic for body text and ensure that heavier weights (font-bold, font-extrabold) are used sparingly for hierarchy emphasis.

Adjust Letter and Line Spacing

Using tracking-* (letter-spacing) and leading-* (line-height) utilities optimizes readability. Increasing letter spacing (tracking-wide) enhances clarity, especially in uppercase text. Apply leading-relaxed for paragraphs and leading-tight for headings to create a distinct visual hierarchy and enhance user experience.