Tailwind CSS - Text Overflow



Tailwind CSS Text Overflow is a collection of predefined classes that control the text behavior when it exceeds element boundaries by allowing truncation, ellipsis overflow (...), or line wrapping (overflow-wrap).

Tailwind CSS Text Overflow Classes

Below is a list of Tailwind CSS Text Overflow classes with properties that manage how text behaves when it exceeds the boundaries of its container.

Class CSS Properties
truncate overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-ellipsis text-overflow: ellipsis;
text-clip text-overflow: clip;

Functionality Of Tailwind CSS Text Overflow Classes

  • truncate: This class truncates text with an ellipsis (...) when it overflows its container.
  • text-ellipsis: This class applies an ellipsis (...) to text that overflows its container.
  • text-clip: This class clips text that overflows its container without any indication (ellipsis or other).

Tailwind CSS Text Overflow Class Examples

Below are examples of Tailwind CSS Text Overflow classes that show how to manage text behavior when it exceeds its container's boundaries.

Prevent Text From Wrapping and Truncate

This example shows how the truncate class truncates text with an ellipsis (...) when it exceeds the container's width.

Example

 



    



    

Tailwind CSS Text Overflow

Applied Truncate text

The longest word in English is pneumonoultramicroscopicsilicovolcanoconiosis, a lung disease caused by inhalation of fine silica particles.

Truncate Overflowing Text

This example shows how the text-ellipsis class displays an ellipsis (...) when text overflows its container, indicating there's more content than is visible.

Example




    


    

Tailwind CSS Text Overflow

Applied Text Ellipsis

The longest word in English is pneumonoultramicroscopicsilicovolcanoconiosis, a lung disease caused by inhalation of fine silica particles.

Truncate Text at Limit

This example shows how the text-clip classes in Tailwind CSS are used to clip the text that exceeds its container's boundaries, ensuring content doesn't visibly overflow outside the specified area.

Example

 



    



    

Tailwind CSS Text Overflow

Applied Text Clip

The longest word in English is pneumonoultramicroscopicsilicovolcanoconiosis, a lung disease caused by inhalation of fine silica particles.

Advertisements