I have a challenge where I need to showcase a list of names separated by commas, pulled from an array in my React component. The HTML output should appear as follows:
<div>
<span>Liza</span>, <span>Eric</span>, <span>Michael</span>, <span>Natalie</span>, <span>Stephan</span>
<a href="#" className="show-more hidden">and {remaining} more...</a>
</div>
However, it is crucial that this list is displayed within 2 lines of content. If the list exceeds this limit, the number of remaining names that are hidden must be shown:
Liza, Eric,
Michael -and 2 more...-
In addition, the display needs to be responsive (only showing 'X more' when truncating) with the list being cut off at the final visible name so that the "and X more" text fits within 2 lines.
Can anyone suggest an effective approach for solving this problem? I suspect a pure CSS solution may not suffice due to the truncation needed.
Thank you!
PS: An image example of the desired outcome would be helpful.