Truncate text in react component
npm install heruka-urgyen/react-truncate-text
import Truncate from "@heruka_urgyen/react-truncate-text"
- In your component:
<Truncate tailLength={tailLength} title={title} className={className}>
text to be truncated
</Truncate>
- Props:
children
(string, required) - text to be truncatedtailLength
(integer, required) - length of tail that is not truncated (tailLength
symbols from the right)title
(string, optional) - tooltip text, defaults tochildren
className
(string, optional) -className
to styleTruncate
container element
- Checkout this repository
npm install
npm run test
npm run example
- Open browser on
localhost:9000
- Edit
example/index.js
, it will be live-reloaded
MIT