Truncated text
Cut long text short and still let people read all of it. .truncate keeps one line, .line-clamp-2 (to 6) keeps a few. When the text really is cut off, pointing at it (or tabbing to it) shows the full text in a tooltip. Text that fits gets no tooltip.
Examples
Quarterly planning notes for the website redesign and the new pricing page
Short title
Quarterly planning notes for the website redesign, the new pricing page, the onboarding emails and the help center rewrite.
<div class="stack max-w-xs">
<p class="truncate box p-2 m-0">Quarterly planning notes for the website redesign and the new pricing page</p>
<p class="truncate box p-2 m-0">Short title</p>
<div class="box p-2"><p class="line-clamp-2 m-0">Quarterly planning notes for the website redesign, the new pricing page, the onboarding emails and the help center rewrite.</p></div>
</div>Point at the first and the last: their full text appears. The second one fits, so it shows nothing.
Give a clamped block no padding of its own: the cut-off line would peek into the bottom padding. Put the padding on a wrapper instead, as the last one does.
In tables and lists
<div class="box p-0 max-w-sm">
<div class="hstack px-4 py-3 border-b"><i class="mi mi-file-text text-muted" aria-hidden="true"></i><span class="truncate flex-1">Brand guidelines - final version for the partners (Nov 2026).pdf</span><span class="text-sm text-muted">2.4 MB</span></div>
<div class="hstack px-4 py-3"><i class="mi mi-file-text text-muted" aria-hidden="true"></i><span class="truncate flex-1">Invoice 1042.pdf</span><span class="text-sm text-muted">98 KB</span></div>
</div>In a row, give the text flex-1 (or min-w-0) so it can shrink and cut.
Good to know
- The whole text is still in the page, so screen readers read all of it and search finds it.
- To show the tooltip from the keyboard too, make the element focusable (
tabindex="0") when it isn't a link or button. - For anything people must read in full (errors, legal text), don't cut it.