1.1.4 • Published 2 years ago

tt-truncate v1.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

workflow

TT Truncate

A tiny, fast, ssr-friendly, zero-deps string truncate React component based on css.

  • Small: 600 B (minified and gzipped). No dependencies. Size Limit controls the size.
  • Fast: 500ms (slowdown x6 - mobile cpu) re-drawing time of 4000+ components. Use only css/html.
  • SSR: Ready for SSR. No DOM manipulation.
  • Native Functionality: Search and copy works as expected from native truncation.
import {Truncate} from "tt-truncate";

<div>
    <Truncate tailLength={2}>I Love JetBrains</Truncate>
</div>

Showcases

See our examples and Showcase paragraph for url.

Install

npm install tt-truncate

Usage

Fit text to container (div). Crop string in the middle.

<div>
    <Truncate tailLength={2}>I Love JetBrains</Truncate>
</div>

Add custom classes

<div>
    <Truncate tailLength={2} className={'custom'}>I Love JetBrains</Truncate>
</div>

Add title

<div>
    <Truncate tailLength={2} title={'Super Title'}>I Love JetBrains</Truncate>
</div>

Props

PropTypeDescription
childrenstringMust be one line string, without special characters. Otherwise the behaviour is undefined
titlestringShown on hover
tailLengthnumberLength of tail
classNamestringClass name applied to text

Browser Compatability

The package works in browsers where display: flex is supported.

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago