Typography
Utilities for controlling how text wraps within an element.
Class | Styles |
---|---|
text-wrap | text-wrap: wrap; |
text-nowrap | text-wrap: nowrap; |
text-balance | text-wrap: balance; |
text-pretty | text-wrap: pretty; |
Use the text-wrap
utility to wrap overflowing text onto multiple lines at logical points in the text:
Use the text-nowrap
utility to prevent text from wrapping, allowing it to overflow if necessary:
Use the text-balance
utility to distribute the text evenly across each line:
For performance reasons browsers limit text balancing to blocks that are ~6 lines or less, making it best suited for headings.
Use the text-pretty
utility to prevent orphans (a single word on its own line) at the end of a text block:
Prefix a text-wrap
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<h1 class="text-pretty md:text-balance ..."> <!-- ... --></h1>
Learn more about using variants in the variants documentation.