Skip to content

albinotonnina/react-truncate-string

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

React Truncate String

Truncate strings like butter.

Build Status

Features

It truncates long long long long...long long strings in the middle!

Requirements

This library relies on spaces for truncation. Thanks @dschinkel for pointing that out.

demo: https://albinotonnina.github.io/react-truncate-string

๐Ÿš€ ultra-blazingly-fast

๐ŸŒˆ ultra-light: 1.76 KB

Table of Contents

Install

yarn add react-truncate-string

Usage

Truncate in the middle of the string

import TruncateString from 'react-truncate-string'

...

render(){

    return  <TruncateString text="your long string" />
}

Truncate the string at 90%

import TruncateString from 'react-truncate-string'

...

render(){
    return  <TruncateString text="your long string" truncateAt={90} />
}

Demos

https://albinotonnina.github.io/react-truncate-string

https://codesandbox.io/s/xvv9r5ozo

Maintainers

@albinotonnina

Contribute

PRs accepted.

TODO

  • truncate by words?
  • min start and end characters option?
  • change debounce time with option?

License

MIT ยฉ 2020 Albino Tonnina