Truncating Multi-line Text By Height – Shave.js

Category: Javascript , Recommended , Text | September 14, 2018
Views Total:1,719 views
Official Page:Go to website
Last Update:September 14, 2018


Truncating Multi-line Text By Height – Shave.js


Shave.js is a lightweight, flexible JavaScript library used for truncating multiple lines of text to a height you specify. With or without custom ellipsis character.

How to use it:


# Yarn
$ yarn add shave
$ npm install shave --save

Place the core JavaScript file shave.js at the end of the document so the page loads faster.

<script src="dist/shave.js"></script>

Or import the shave as a module.

import shave from 'shave';

Call the shave function, specify the target text wrapping element and the max height for text truncating.

shave('p', 70);

Add a custom ellipsis to the end of the truncated text.

shave('selector', maxheight, {
   character: '......'


v2.5.0 (09/14/2018)

  • Update to the latest version

You Might Be Interested In:

Leave a Reply