Clamp
The Clamp engine truncates text to a specified number of lines using word-based ellipsis. It preserves the original text, measures available width, and re-applies clamping whenever layouts change.
Basic usage
Add data-clamp="N" to any text element to clamp it to N lines. The engine preserves the original text and re-applies clamping when layouts change.
<span class="description" data-clamp="2">Example description text that will be clamped to two lines</span>
Responsive
Use the same size and orientation modifiers as other framework components. Specificity (most specific first): size + orientation (e.g. data-clamp-md-portrait), size only (data-clamp-sm, -md, -lg), orientation only (data-clamp-portrait), then base data-clamp.
<span class="description" data-clamp="2" data-clamp-md="4" data-clamp-portrait="1">Clamp to 2 lines by default, 4 on medium+ screens, 1 in portrait</span>
Backward Compatibility
Legacy class tokens are supported and mapped to the Clamp engine automatically:
clamp--none disables clamping, and
clamp--1 through
clamp--50 request N lines.
<span class="description clamp--2">Example description with legacy class clamped to two lines of text</span>