Skip to main content
Login

Sign in to access your account

Truncate Text - National Design System

A CSS class that clips long text to a set number of lines and ends it with an ellipsis

Overview

Truncate Text is one class, nds-truncate, and one custom property, --truncate, which sets how many lines show.

Pick another component when:

Markup

Preview
National Digital Transformation Strategy and Implementation Roadmap

The unified portal gives access to more than 200 government services from 35 ministries. Citizens can submit applications, track requests, book appointments and get notices about their open requests. The portal supports biometric sign-in, digital signatures and secure document uploads.

<div class="nds-card nds-stroke"> <div class="nds-card-content"> <div class="nds-card-text"> <span class="nds-card-title nds-truncate">National Digital Transformation Strategy and Implementation Roadmap</span> <p class="nds-card-description nds-truncate">The unified portal gives access to more than 200 government services from 35 ministries. Citizens can submit applications, track requests, book appointments and get notices about their open requests. The portal supports biometric sign-in, digital signatures and secure document uploads.</p> </div> </div> </div>

Built-in Features

  • CSS Only

    One class and no JavaScript. There is nothing to start, and nothing to clean up.

  • Any Text Element

    Works on a heading, a paragraph, a <span> or a <div>. A <span> becomes a block, so it takes its own line.

  • Container Width

    When the container gets wider or narrower, the text clips at the new width.

  • Full Text for Screen Readers

    The class clips only what shows. The full text stays in the page, so a screen reader reads all of it.

Best Practices

  • Use it for text that can be too long for its space: card titles and descriptions, table cells, menu labels and list items.
  • Use 1 line for titles and labels, 2 for short descriptions and 3 for previews.
  • Give the user another way to read the full text: a title attribute, a Tooltip, or a link to the full page.
  • Do not clip text the user must read to finish a task, such as form labels, error messages or legal text.
  • If every card description is clipped, the text is too long. Shorten the text first.
  • The text clips only when it needs more lines than --truncate allows. To clip a short text, give its element a max-width.
  • The class has zero specificity, so a component rule that sets display on the same element wins, and the text does not clip. When you add it to a part of another component, check that the ellipsis shows.

API

CSS Custom Properties

Set it in the style attribute of the element with nds-truncate: style="--truncate: 3". On a parent, it changes every nds-truncate element inside it.

Property Default Controls
--truncate 1 How many lines show before the ellipsis. A whole number above 0
Last Modified Date: 10/10/2026 - 05:28 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks