I want to display a list of comma-separated names that is coming from an array in my react component. The rendered html looks something like:
<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, this list needs to be displayed in up to 2 lines of content. If the list exceeds the 2 lines, I need to display the quantity of the remaining names that are hidden:
Liza, Eric,
Michael -and 2 more...-
The list also has to be responsive (only display 'X more' if I am truncating) and I need to truncate the list at the end of the last displayed name so the "and X more" text fits within 2 lines.
Can anyone recommend an approach I should take to solve this problem? I believe that pure CSS solution might not work because of the truncation.
Thanks!
PD A screenshot of what I want to achieve: