Components › Utilities

Truncation

When applying truncation, place the full text in a title attribute so that it’s accessible on hover.

Single LineSingle Linedev ready

Preview

Code

<dl class="slds-size--1-of-2">
  <dt class="slds-text-title--caps">Field 4</dt>
  <dd>
    <p class="slds-truncate" title="Long text field with many lines and truncation will look like this. Even though the text might go on for ages and ages.">Long text field with many lines and truncation will look like this. Even though the text might go on for ages and ages.</p>
  </dd>
</dl>

Max WidthMax Width › 25%Max Width › 33%Max Width › 50%Max Width › 66%Max Width › 75%Max Widthdev ready

Preview

Code

<ul>
  <li class="slds-list__item slds-m-right--large slds-grid slds-truncate_container--25">
    <span>To:</span>
    <span class="slds-m-left--xx-small slds-truncate" title="Lei Chan"><a href="javascript:void(0);">Lei Chan</a></span>
    <span class="slds-m-left--xx-small slds-no-flex"> + 44 more</span>
  </li>
  <li class="slds-list__item slds-m-right--large slds-grid slds-truncate_container--25">
    <span>To:</span>
    <span class="slds-m-left--xx-small slds-truncate" title="Lei Chan with Long Name"><a href="javascript:void(0);">Lei Chan with Long Name</a></span>
    <span class="slds-m-left--xx-small slds-no-flex"> + 44 more</span>
  </li>
  <li class="slds-list__item slds-m-right--large slds-grid slds-truncate_container--25">
    <span>To:</span>
    <span class="slds-m-left--xx-small slds-truncate" title="Lei Chan with Long Name that might go on for quite some distance futher than you might expect"><a href="javascript:void(0);">Lei Chan with Long Name that might go on for quite some distance futher than you might expect</a></span>
    <span class="slds-m-left--xx-small slds-no-flex"> + 44 more</span>
  </li>
</ul>

Component Overview

If problems occur when using truncation with elements that use flexbox, you might need to add the .slds-has-flexi-truncate class on the flexbox child node ( .slds-col or .slds-col--padded elements) that contains the truncated text.

Note: There is an iOS bug that is triggered when you add a component from Visualforce into S1 using an iFrame. The truncated element does not recognize its width.

Usage

This table gives you a quick overview of the SLDS CSS classes that can be applied to this component.
Class NameUsage
.slds-truncate
Applied to:

any element

Outcome:

Creates truncated text

Required:

No, optional element or modifier

Comments:

Truncation will occur at the parent width if a width is not specified

.slds-has-flexi-truncate
Applied to:

.slds-col
.slds-col--padded

Outcome:

Allows truncation in nested flexbox containers

Required:

No, optional element or modifier

Comments:

This class is placed on a parent element that contains a flexbox element containing .slds-truncate. For example — for a media object that is nested in a grid column and contains truncation — the grid column would require this class.