Use the
line-clamp-*
utilities to truncate a block of text after a specific number of lines.
Boost your conversion rate
Nulla dolor velit adipisicing duis excepteur esse in duis nostrud occaecat mollit incididunt deserunt sunt. Ut ut sunt laborum ex occaecat eu tempor labore enim adipisicing minim ad. Est in quis eu dolore occaecat excepteur fugiat dolore nisi aliqua fugiat enim ut cillum. Labore enim duis nostrud eu. Est ut eiusmod consequat irure quis deserunt ex. Enim laboris dolor magna pariatur. Dolor et ad sint voluptate sunt elit mollit officia ad enim sit consectetur enim.
Lindsay Walton
<article><time>Mar 10, 2020</time><h2>Boost your conversion rate</h2><pclass="line-clamp-3">Nulla dolor velit adipisicing duis excepteur esse in duis nostrud occaecat mollit incididunt deserunt sunt. Ut ut sunt laborum ex occaecat eu tempor labore enim adipisicing minim ad. Est in quis eu dolore occaecat excepteur fugiat dolore nisi aliqua fugiat enim ut cillum. Labore enim duis nostrud eu. Est ut eiusmod consequat irure quis deserunt ex. Enim laboris dolor magna pariatur. Dolor et ad sint voluptate sunt elit mollit officia ad enim sit consectetur enim.</p><imgsrc="..."/>
Lindsay Walton
</div></article>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:line-clamp-4 to only apply the line-clamp-4 utility on hover.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:line-clamp-4 to apply the line-clamp-4 utility at only medium screen sizes and above.
By default, Tailwind provides the six line-clamp utilities. You can customize these values by editing theme.lineClamp or theme.extend.lineClamp in your tailwind.config.js file.