Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tsung-ju/react-truncate-lines

React component for text truncation.
https://github.com/tsung-ju/react-truncate-lines

Last synced: 11 days ago
JSON representation

React component for text truncation.

Awesome Lists containing this project

README

        

# react-truncate-lines

React component for text truncation. Number of lines is measured using [Element.getClientRects()](https://developer.mozilla.org/en-US/docs/Web/API/Element/getClientRects).

[Try it out](https://tsung-ju.github.io/react-truncate-lines/demo)

## Install

```sh
npm install react-truncate-lines
```

## Usage

API is similar to [react-truncate](https://www.npmjs.com/package/react-truncate).

```js
import { TruncateLines } from "react-truncate-lines";

function MyComponent() {
return (
...Read More}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.

);
}
```

For multiline text use ``.