Line Clamp
Utilities for clamping text to a specific number of lines.
Use the utilities to truncate a block of text after a specific number of lines.
Undoing line clamping
<p class="line-clamp-3 lg:line-clamp-none">
</p>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:line-clamp-4
to only apply the utility on hover.
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
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.
<p class="line-clamp-3 md:line-clamp-4">
<!-- ... -->
</p>
By default, Tailwind provides the six utilities. You can customize these values by editing theme.lineClamp
or theme.extend.lineClamp
in your tailwind.config.js
file.
tailwind.config.js
Learn more about customizing the default theme in the theme customization documentation.
Arbitrary values
<p class="line-clamp-[7]">
</p>
Learn more about arbitrary value support in the arbitrary values documentation.