/react-truncate-text

Truncate text in react component

Primary LanguageJavaScriptMIT LicenseMIT

React-truncate-text

Truncate text in react component

How to use

  1. npm install heruka-urgyen/react-truncate-text
  2. import Truncate from "@heruka_urgyen/react-truncate-text"
  3. In your component:
  <Truncate tailLength={tailLength} title={title} className={className}>
    text to be truncated
  </Truncate>
  1. Props:
  • children (string, required) - text to be truncated
  • tailLength (integer, required) - length of tail that is not truncated (tailLength symbols from the right)
  • title (string, optional) - tooltip text, defaults to children
  • className (string, optional) - className to style Truncate container element

Development / Testing / Example

Live example

  1. Checkout this repository
  2. npm install
  3. npm run test
  4. npm run example
  5. Open browser on localhost:9000
  6. Edit example/index.js, it will be live-reloaded

License

MIT