Skip to content

Support for truncating multiple lines in Tailwindcss

License

Notifications You must be signed in to change notification settings

fossbarrow/tailwindcss-multiline-truncate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tailwindcss Multiline Truncate Support

MIT Licensed PR friendly repository Follow Fossbarrow on Twitter

Support for truncating multiple lines in Tailwindcss.

Installation

npm

npm install @fossbarrow/tailwindcss-multiline-truncate --save

yarn

yarn add @fossbarrow/tailwindcss-multiline-truncate 

Usage

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... 

Utilities

This plugin generates the following utilities:

.truncate-[key]-lines {
    'overflow': 'hidden',
    'display': '-webkit-box',
    '-webkit-box-orient': 'vertical',
    '-webkit-line-clamp': [value],
}

Variants:

You can also add variants just like any rule:

//tailwind.config.js
{
    ...
    plugins: [
       require('@fossbarrow/tailwindcss-multiline-truncate')(['responsive', 'hover']), 
    ]
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.