Poor man's multiline ellipsis component for React.JS https://xiaody.github.io/react-lines-ellipsis/
To install the stable version:
npm install --save react-lines-ellipsis
import LinesEllipsis from 'react-lines-ellipsis'
<LinesEllipsis
text='long long text'
maxLine='3'
ellipsis='...'
trimRight
basedOn='letters'
/>
The text you want to clamp.
Max count of lines allowed. Default 1
.
Text content of the ellipsis. Default …
.
Trim right the clamped text to avoid putting the ellipsis on an empty line. Default true
.
Split by letters
or words
. By default it uses a guess based on your text.
- only accept plain text by default. Use
lib/html.js
for experimental rich html support - can be fooled by some special styles:
::first-letter
, ligatures, etc. - require modern browsers env
import HTMLEllipsis from 'react-lines-ellipsis/lib/html'
<HTMLEllipsis
unsafeHTML="simple html content"
maxLine="5"
ellipsis="..."
basedOn="letters"
/>
- demo page
- test cases
- improve performance