Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Simple multiline ellipsis component for React.JS

License

Notifications You must be signed in to change notification settings

nfl/react-lines-ellipsis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version dependencies Status js-standard-style

react-lines-ellipsis

Poor man's multiline ellipsis component for React.JS https://xiaody.github.io/react-lines-ellipsis/

Installation

To install the stable version:

npm install --save react-lines-ellipsis

Usage

import LinesEllipsis from 'react-lines-ellipsis'

<LinesEllipsis
  text='long long text'
  maxLine='3'
  ellipsis='...'
  trimRight
  basedOn='letters'
/>

Options

props.text {String}

The text you want to clamp.

props.maxLine {Number|String}

Max count of lines allowed. Default 1.

props.ellipsis {String}

Text content of the ellipsis. Default .

props.trimRight {Boolean}

Trim right the clamped text to avoid putting the ellipsis on an empty line. Default true.

props.basedOn {String}

Split by letters or words. By default it uses a guess based on your text.

Limitations

  • 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

Experimental html truncation

import HTMLEllipsis from 'react-lines-ellipsis/lib/html'

<HTMLEllipsis
  unsafeHTML="simple html content"
  maxLine="5"
  ellipsis="..."
  basedOn="letters"
/>

Dev TODOs

  • demo page
  • test cases
  • improve performance

About

Simple multiline ellipsis component for React.JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%