# react-text-trimmer

> React component that trims overflowing multi line text and adds a specified tail

Latest version **3.0.0** (published 2020-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-text-trimmer
pnpm add react-text-trimmer
yarn add react-text-trimmer
bun add react-text-trimmer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-05-03 |
| First published | 2016-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Michal Dedys |
| Maintainers | mikededys |
| Keywords | trim, ellipsis, react |

## Links

- npm: https://www.npmjs.com/package/react-text-trimmer
- Repository: https://github.com/mdedys/react-text-trimmer
- Homepage: https://github.com/mdedys/react-text-trimmer#readme
- Issues: https://github.com/mdedys/react-text-trimmer/issues
- npm.io page: https://npm.io/package/react-text-trimmer

## Dependencies (1)

- [debounce](https://npm.io/package/debounce.md) ^1.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2020-05-03
- 3.0.0-rc3 — 2020-05-02
- 3.0.0-rc2 — 2020-05-02
- 3.0.0-rc1 — 2020-05-01
- 2.0.0 — 2017-11-25
- 1.0.3 — 2017-11-16
- 1.0.2 — 2017-01-27
- 1.0.1 — 2017-01-07
- 1.0.0 — 2017-01-05
- 0.0.2 — 2016-12-08
- 0.0.1 — 2016-12-08

## README

# react-text-trimmer

[![NPM version][npm-image]][npm-url]
[![mdedys](https://circleci.com/gh/mdedys/react-text-trimmer.svg?style=svg)](https://app.circleci.com/pipelines/github/mdedys/react-text-trimmer)
[![dependencies Status](https://david-dm.org/mdedys/react-text-trimmer/status.svg)](https://david-dm.org/mdedys/react-text-trimmer)
[![devDependencies Status](https://david-dm.org/mdedys/react-text-trimmer/dev-status.svg)](https://david-dm.org/mdedys/react-text-trimmer?type=dev)
[![peerDependencies Status](https://david-dm.org/mdedys/react-text-trimmer/peer-status.svg)](https://david-dm.org/mdedys/react-text-trimmer?type=peer)

## Installation

Install from NPM:

```shell
yarn install react-text-trimmer
```

## Usage

### Options

`lines`: number of lines to truncate text

`prefix`: prefix to attach to beginning of text, default is empty string

`suffix`: suffix to attach to end of text, default is ...

`interval`: dobounce interval, default is 166

There is two ways to use the text trimmer. One can use the component or the react hook.

### Components

Props: 

`options`: TextTrimmerOptions

```javascript
import TextTrimmer from "react-text-trimmer"

...
<TextTrimmer>
  Long text.........
<TextTrimmer>

...

```

### Hook

```javascript
import { useTextTrimmer } from "react-text-trimmer"

...
const ref = React.useRef(null)

const value = useTextTrimmer(text, ref, options)

return <div ref={ref}>{value}</div>

...
```

### Code Style

This repository is configured with [EditorConfig][editorconfig].

[npm-url]: https://npmjs.org/package/react-text-trimmer
[npm-image]: https://img.shields.io/npm/v/react-text-trimmer.png
[ci-url]: https://travis-ci.org/mdedys/react-text-trimmer
[ci-image]: https://img.shields.io/travis-ci/mdedys/react-text-trimmer.svg
[editorconfig]: http://editorconfig.org/

---
_Source: https://npm.io/package/react-text-trimmer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
