Typography
Utilities for clamping text to a specific number of lines.
Class | Styles |
---|---|
line-clamp-<number> | overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: <number>; |
line-clamp-none | overflow: visible;
display: block;
-webkit-box-orient: horizontal;
-webkit-line-clamp: unset; |
line-clamp-(<custom-property>) | overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(<custom-property>); |
line-clamp-[<value>] | overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: <value>; |
Use line-clamp-<number>
utilities like line-clamp-2
and line-clamp-3
to truncate multi-line text after a specific number of lines:
Use line-clamp-none
to undo a previously applied line clamp utility:
<p class="line-clamp-3 lg:line-clamp-none"> <!-- ... --></p>
Use the line-clamp-[<value>]
syntax to set the number of lines based on a completely custom value:
<p class="line-clamp-[calc(var(--characters)/100)] ..."> <!-- ... --></p>
For CSS variables, you can also use the line-clamp-(<custom-property>)
syntax:
<p class="line-clamp-(--my-line-count) ..."> <!-- ... --></p>
This is just a shorthand for line-clamp-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a line-clamp
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="line-clamp-3 md:line-clamp-4 ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.