react-row-ellipsis
v2.1.2
Published
The package will allow you to easily cut a text to the indicated amount of lines
Downloads
89
Maintainers
Readme
📄 Description
Simple easy to use React component which allow you to truncate a text with line indication. You can truncate not only simple string but also any elements/tags inside the component. Lines amount are configurable and works based on container or screen size. So you don't have to worry about different screen sizes. Lines amount will stay exactly the same.
📦 Installation
Just run the following command at the root of your project:
npm install react-row-ellipsis
# or
yarn add react-row-ellipsis
✨ Demo
Feel free to check the demo where you can test different settings for the component:
🚀 Usage
Just import the component and you are good to go
import { Ellipsis } from 'react-row-ellipsis'
<Ellipsis lines={3}>
The long text goes here
</Ellipsis>
🌉 Examples
Basic example. Truncate simple string:
<Ellipsis lines={2}>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Cum quidem dolorum sapiente, incidunt perferendis praesentium.
</Ellipsis>
Example with the tags inside. You can use different tags but you want to use inline tags:
<Ellipsis lines={1}>
<strog>Lorem, ipsum dolor.</strong>
<span>Lorem ipsum dolor sit <a href="#">amet</a> consectetur adipisicing elit.</span>
</Ellipsis>
Example with another tag. The text will be rendered in the <div>
tag:
<Ellipsis lines={3} as="div">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Soluta eum, quaerat quidem unde deserunt harum sint ex cum.
</Ellipsis>
🛠 Props
| Props | Type | Default | Description | |-------|--------|---------|--------------------------------| | lines | number | 1 | Set amount of lines to display | | as | string | p | Set render tag |
🤝 Contribution
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
📝 License
This project is MIT licensed.