Tailwind CSS Line-height
Tailwind Line Height
The line-height
utility class in Tailwind CSS allows you to control the height of lines within text elements. With Tailwind's line-height class, you can adjust the spacing between lines to achieve the desired line height and improve the readability of your text.
Applying Tailwind Line Height
To apply line height to an element, you can use the leading-{value} utility class, where {value} represents the line height value.
- leading-none: Sets the line height to none, causing the lines to overlap.
- leading-tight: Sets a tight line height, reducing the spacing between lines.
- leading-snug: Sets a snug line height, slightly reducing the spacing between lines.
- leading-normal: Sets the default line height.
- leading-relaxed: Sets a relaxed line height, increasing the spacing between lines.
- leading-loose: Sets a loose line height, further increasing the spacing between lines.
<p class="leading-snug"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda, quia temporibus eveniet a libero incidunt suscipit.</p><p class="leading-9"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda, quia temporibus eveniet a libero incidunt suscipit.</p>
Preview
Responsive Line Height
Tailwind CSS allows you to apply line height classes responsively at different breakpoints. To use responsive line height classes, you can append the breakpoint prefix to the utility class. For example, md:leading-snug sets a snug line height starting from the medium breakpoint and above.
<p class="leading-normal md:leading-snug"> Lorem ipsum dolor sit amet.</p>
In the above example, the line height is set to normal by default (leading-normal), but starting from the medium breakpoint and above, the line height is changed to snug (md:leading-snug).
Tailwind Line Height Class Table
Class | Properties |
---|---|
leading-3 | line-height: .75rem; |
leading-4 | line-height: 1rem; |
leading-5 | line-height: 1.25rem; |
leading-6 | line-height: 1.5rem; |
leading-7 | line-height: 1.75rem; |
leading-8 | line-height: 2rem; |
leading-9 | line-height: 2.25rem; |
leading-10 | line-height: 2.5rem; |
leading-none | line-height: 1; |
leading-tight | line-height: 1.25; |
leading-snug | line-height: 1.375; |
leading-normal | line-height: 1.5; |
leading-relaxed | line-height: 1.625; |
leading-loose | line-height: 2; |
Windframe Tailwind blocks
Build modern projects using Bootstrap 5 and Contrast
Trying to create components and pages for a web app or website from
scratch while maintaining a modern User interface can be very tedious.
This is why we created Contrast, to help drastically reduce the amount of time we spend doing that.
so we can focus on building some other aspects of the project.
Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants.
Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for
building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.