Line Clamp

Utilities for visually truncating text after a fixed number of lines.


Class reference

ClassProperties
line-clamp-1overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1;
line-clamp-2overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
line-clamp-3overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
line-clamp-4overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
line-clamp-5overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5;
line-clamp-6overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6;
line-clamp-7overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 7;
line-clamp-8overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 8;
line-clamp-9overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 9;
line-clamp-10overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 10;
line-clamp-none-webkit-line-clamp: unset;

# Usage

Use the line-clamp-{n} utilities to specify how many lines of text should be visible before truncating:

Et molestiae hic earum repellat aliquid est doloribus delectus. Enim illum odio porro ut omnis dolor debitis natus. Voluptas possimus deserunt sit delectus est saepe nihil. Qui voluptate possimus et quia. Eligendi voluptas voluptas dolor cum. Rerum est quos quos id ut molestiae fugit.

<p class="line-clamp-3 ...">Lorem ipsum dolor sit amet ...</p>

To remove any line-clamping, use line-clamp-none:

Et molestiae hic earum repellat aliquid est doloribus delectus. Enim illum odio porro ut omnis dolor debitis natus. Voluptas possimus deserunt sit delectus est saepe nihil. Qui voluptate possimus et quia. Eligendi voluptas voluptas dolor cum. Rerum est quos quos id ut molestiae fugit.

<p class="line-clamp-3 md:line-clamp-none ...">Lorem ipsum dolor sit amet ...</p>

Note that the line-clamp-{n} set other properties like display and overflow in addition to -webkit-line-clamp which are not unset by line-clamp-none, so depending on what you are trying to achieve you may need to explicitly override those properties with utilities like flex or overflow-visible as well.

# Responsive

To control the line-clamp at a specific breakpoint, add a {screen}: prefix to any existing z-index utility. For example, use md:line-clamp-5 to apply the line-clamp-5 utility at only medium screen sizes and above.

For more information about Elements’ responsive design features, check out the Responsive Design documentation.