npm i --save-dev tailwind-leading-trim
or
yarn add -D tailwind-leading-trim
To set up the plugin, follow these steps:
- Import the plugin in
tailwind.config.js
:
module.exports = {
...
theme: {
fontFamily: {
"sans": "Inter",
},
fontMetrics: {
"capHeight": 2048,
"ascent": 2728,
"descent": -680,
"lineGap": 0,
"unitsPerEm": 2816,
},
},
...
plugins: [require('tailwind-leading-trim')],
}
- Use the Tailwind class to trim leading on both the start and the end:
<div className="text-4xl font-sans leading-trim-both">
The quick brown fox jumps over the lazy dog
</div>
- You can also trim just the start or the end:
Trim the start:
<div className="text-4xl font-sans leading-trim-start">
The quick brown fox jumps over the lazy dog
</div>
Trim the end:
<div className="text-4xl font-sans leading-trim-end">
The quick brown fox jumps over the lazy dog
</div>
Created by Burak Aslan.