Helpers
Text truncation
Cut long text off with an ellipsis instead of breaking the layout. When text is cut off, pointing at it (or focusing it) shows the whole thing in a tooltip — automatically.
text-truncate: a customer note that is far too long to fit on one line here
line-clamp-2: up to two lines, then an ellipsis — great for message previews and card descriptions that can be any length.
Short text — no tooltip
<div class="stack gap-3 max-w-sm">
<div class="text-truncate">text-truncate: a customer note that is far too long to fit on one line here</div>
<div class="line-clamp-2">line-clamp-2: up to two lines, then an ellipsis — great for message previews and card descriptions that can be any length.</div>
<div class="text-truncate">Short text — no tooltip</div>
</div>
Point at the first two lines: the full text appears. The third fits, so there is no tooltip.
Inside a row
In a flex row, text can only shrink if its box can: add min-w-0 (or flex-1 min-w-0) next to text-truncate.
Quarterly-report-final-version-3-really-final.pdf
2.4 MB
<div class="hstack bg-1 rounded-lg p-3">
<i class="mi mi-file-text text-xl shrink-0"></i>
<span class="flex-1 min-w-0 text-truncate">Quarterly-report-final-version-3-really-final.pdf</span>
<span class="text-sm text-muted shrink-0">2.4 MB</span>
</div>
| Class | What it does |
|---|---|
text-truncate | one line, then … |
line-clamp-1 · … · line-clamp-6 | that many lines, then … (line-clamp-none undoes it) |
min-w-0 | lets text shrink inside a flex row |
| Tooltip | shown only when the text is really cut off; data-moey-tooltip="false" turns it off |