# react-truncator

> A react component that horizontally truncates text

Latest version **0.0.5** (published 2018-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-truncator
pnpm add react-truncator
yarn add react-truncator
bun add react-truncator
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2018-10-24 |
| First published | 2018-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 582.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marco Segreto |
| Maintainers | msecret |

## Links

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

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^16.4.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [webpack](https://npm.io/package/webpack.md) ^3.11.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.4.2
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.2
- [babel-plugin-transform-class-properties](https://npm.io/package/babel-plugin-transform-class-properties.md) ^6.24.1

## Recent versions

- 0.0.5 (latest) — 2018-10-24
- 0.0.4 — 2018-10-23
- 0.0.3 — 2018-08-14
- 0.0.2 — 2018-08-13
- 0.0.1 — 2018-08-09

## README

## About

A react component that horizontally truncates text based on how much width it fills in it's parent container.

## Install

Install from npm and you should be ready. The package will use your version of react from your project.

```
npm install --save react-truncator
```

## Use

Currently, the truncator component works best when used with block level elements rather the inline or inline block elements as this allows it to determine it's full size. The component takes the following props:

- **text**: The text to truncate as a string
- **extraSpacing**: Any extra spacing the text might need.
- **minWidth**: Override the size of the space the text takes up with a minimum width

```js
import Truncator from 'react-truncator'

// ...
<Truncator
  text={yourText}
  extraSpacing={20}
/>
```

## How it works

The truncator will take a first pass and render the text with CSS styles so it fills up it's full space within it's parent. From here the truncator will know the text's width and will use an algorithm to determine how many characters it needs to truncate in order to fit within the space. Once it determines this it re-renders with the truncated text.

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