Skip to content

Truncation

Truncation utilities clip overflowing text and add an ellipsis. They are for one line; multi-line clamping is a content decision and stays in your CSS.

Class Effect
text-truncate display: inline-block, overflow: hidden, text-overflow: ellipsis, white-space: nowrap
truncate The same overflow rules without changing display
<p class="text-truncate" style="max-width: 18rem">A very long file name that should not wrap</p>
<p class="truncate" style="max-width: 18rem">Works on an element whose display is already set</p>

The two differ only in the display value. text-truncate is convenient on an inline element; truncate is the safer choice inside a flex or grid item, where changing display would break the layout.

A flex child refuses to shrink below its content by default. Add min-w-0 so the truncation can take effect:

<div class="d-flex gap-2">
<span class="flex-shrink-0">Label</span>
<span class="truncate min-w-0">A long value that shrinks with the row</span>
</div>

There is no utility for multi-line clamping because the line count and the fallback are content decisions:

.clamp-3 {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}

Truncation has no breakpoint variants. If the line count changes with the viewport, write the clamp in a media query.