A “Show More” component, when the content exceeds the set number of display lines, an expand button will appear to view more content.
Usage
Use it like a normal component, just pass the long text as the children prop.
Custom buttons
If use custom React elements for the more / less props, you can bind the Ref value to the <ShowMore /> component, and receive the toggleLines method through ref.
This method is very flexible for business, in addition to replacing the UI of the button, you can also change its purpose. For example, the more button can be replaced with the ability to click to invoke a pop-up window or redirect to another page.
Type Declarations
This is the Props type of the component, inherits most of the Props from the Truncate component.
Please note: Props removed from TruncateProps by Omit are ignored and will not be passed to the <Truncate /> component.
This component supports React’s reference forwarding.
Live demo
Here is a basic example that could theoretically be suitable for any project. Adjust the slider to control how it displays in different situations.