Text Wrap
Controls how text is wrapped within an element.
| Class | Style |
|---|---|
tw-b | text-wrap: balance |
tw-n | text-wrap: nowrap |
tw-p | text-wrap: pretty |
tw-w | text-wrap: wrap |
Wrap
Initial value
The text will wrap to the next line when it reaches the end of the container.
<div class="bg-indigo-1 p-4 rad-1"> <div class="bg-white d-g g-4 max-w-80 mx-auto p-4 rad-1"> <div class="fs-xl fw-600 tc-slate tw-w">Letters to Anne (Springtime'23 message)</div> <p class="fs-sm tc-gray-7"> Hi, Anne. It's finally springtime here on Earth! I can't stand windy or cold days, so I'm very excited for the spring. There are so many beautiful, colorful trees where I live. </p> </div></div>Balance
The text will be wrapped in a way that balances the line lengths, creating a more visually appealing layout.
<div class="bg-indigo-1 p-4 rad-1"> <div class="bg-white d-g g-4 max-w-80 mx-auto p-4 rad-1"> <div class="fs-xl fw-600 tc-slate tw-b">Letters to Anne (Springtime'23 message)</div> <p class="fs-sm tc-gray-7"> Hi, Anne. It's finally springtime here on Earth! I can't stand windy or cold days, so I'm very excited for the spring. There are so many beautiful, colorful trees where I live. </p> </div></div>No Wrap
The text will not wrap to the next line, and it will overflow the container if it exceeds the width.
<div class="bg-indigo-1 p-4 rad-1"> <div class="bg-white d-g g-4 max-w-80 mx-auto p-4 rad-1"> <div class="fs-xl fw-600 tc-slate tw-nw">Letters to Anne (Springtime'23 message)</div> <p class="fs-sm tc-gray-7"> Hi, Anne. It's finally springtime here on Earth! I can't stand windy or cold days, so I'm very excited for the spring. There are so many beautiful, colorful trees where I live. </p> </div></div>Pretty
The text will be wrapped in a way that maintains a visually pleasing appearance, often used for better readability.
<div class="bg-indigo-1 p-4 rad-1"> <div class="bg-white d-g g-4 max-w-80 mx-auto p-4 rad-1"> <div class="fs-xl fw-600 tc-slate tw-p">Letters to Anne (Springtime'23 message)</div> <p class="fs-sm tc-gray-7"> Hi, Anne. It's finally springtime here on Earth! I can't stand windy or cold days, so I'm very excited for the spring. There are so many beautiful, colorful trees where I live. </p> </div></div>Using utility variants
Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.
Using media queries
You can combine responsive breakpoints like sm:tw-*, md:tw-*, lg:tw-*, and xxl:tw-* to allow targeting specific utilities in different viewports.
Using hover states
Alternatively, you can apply :hover by using h:tw-* utility to override elements and change their values when hovering over them.