Support for truncating multiple lines in Tailwindcss.
npm
npm install @fossbarrow/tailwindcss-multiline-truncate --save
yarn
yarn add @fossbarrow/tailwindcss-multiline-truncate
Register the plugin in tailwind.config.js
.
// tailwind.config.js
{
plugins: [
require('@fossbarrow/tailwindcss-multiline-truncate')(),
],
}
Add the truncate settings and modify after own desire in the same file.
// tailwind.config.js
{
theme: {
truncate: {
lines: {
3: '3',
5: '5',
8: '8',
}
}
}
Now, in your vue component, you can use the plugin like so:
<p class="truncate-3-lines">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, porro
exercitationem dolorum nemo molestiae excepturi eos non suscipit, cupiditate
incidunt libero nisi atque voluptas sint reiciendis placeat! Eos, magnam
asperiores? ipsum dolor sit amet consectetur adipisicing elit.
libero nisi atque voluptas sint reiciendis!
</p>
Output:
Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis, porro
exercitationem dolorum nemo molestiae excepturi eos non suscipit, cupiditate
incidunt libero nisi atque voluptas sint reiciendis placeat! Eos, magnam...
This plugin generates the following utilities:
.truncate-[key]-lines {
'overflow': 'hidden',
'display': '-webkit-box',
'-webkit-box-orient': 'vertical',
'-webkit-line-clamp': [value],
}
You can also add variants just like any rule:
//tailwind.config.js
{
...
plugins: [
require('@fossbarrow/tailwindcss-multiline-truncate')(['responsive', 'hover']),
]
}
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.