Ellipsed: JavaScript library for multiline text ellipsis.

综合技术 2017-11-15


What is Ellipsed?

Ellipsed is a JavaScript library for generating multi-lined ellipsed text.

Indicating the number of visible lines, it will truncate the text at the correct position in targeted elements.


You can see the demo here: https://nzambello.github.io/ellipsed/

The example/ directory of this repo contains the demo showed above. To start it on your local machine, clone the repository and install it by following the installation instructions below, then start it with npm start (or with yarn start ).


# Yarn
yarn add ellipsed

npm install --save ellipsed

# Bower
bower install ellipsed


Call the ellipsis method with three parameters:

ellipsis(selector, rows, options);
  • selector - A CSS selector string used to target the element for truncation
  • rows - An integer value used as the number of rows that should be visible, following words will be trucated with the replaceStr (default is '...' ).
  • options - Allows an options object to be passed to further customise the functionality. See options section below for details.


Options can be passed through the method using the third parameter, which provides greater control.

Name Type Default Description
replaceStr string '...' The string that substituted following the trucated string.
responsive boolean false If true, the method is re-called on resize event, so the number of rows is preserved.
debounceDelay integer 250 If responsive option is set, it's the delay value for resizing events debouncing.


Ellipsed is provided as a UMD module.

You can use it as a ES6 module:

import { ellipsis } from 'ellipsed';

As a CommonJS module:

var { ellipsis } = require('ellipsed');

As an AMD module:

], function(ellipsed) {
  var ellipsis = ellipsed.ellipsis;

Or as a global module in the browser:

var ellipsis = window.ellipsed.ellipsis;

Browser support

The library has been tested on:

  • Google Chrome 60+
  • Firefox 55+
  • Safari 10+
  • Edge 14+
  • IE 9+


New contributors are warmly welcome, see the CONTRIBUTING.md file for other information.


责编内容by:Github (源链)。感谢您的支持!


Node入门教程(7)第五章:node 模块化(下) npm与yarn详解... Node的包管理器 JavaScript缺少包结构的定义,而 CommonJS 定义了一系列的规范。而NPM的出现则是为了在CommonJS规范的基...
Npm vs Yarn 之备忘详单 有则笑话,如此讲到:“老丈人爱吃核桃,昨天买了二斤陪妻子送去,老丈人年轻时练过武,用手一拍核桃就碎了,笑着对我说:你还用锤子,你看我用手就成。我嘴一抽,来了句:...
React v16.2.0: Improved Support for Fragments React 16.2 is now available! The biggest addition is improved support for retur...
Ellipsed: JavaScript library for multiline text el... ellipsed What is Ellipsed? Ellipsed is a JavaScript library for generating m...
为什么我们应该使用 pnpm(译) pnpm 是又一个 Node.js 包管理工具。它可以替换 npm, 而且 npm 更快更高效。 能有多快? 3 倍! 可以在 ...