DEV Community

Discussion on: Truncate string with ellipsis

Collapse
 
ademola_isr profile image
ADEMOLA OGUNMOKUN

So how does the user read the truncated strings If wishes to do so

Collapse
 
ip127001 profile image
Rohit Kumawat • Edited

Use a title attribute on the div like example below:

const longText = "Hey everyone, This code shows how we can truncate long strings so that they can shown as ellipsis. we can use 100% width to adjust text in one line."

<div title={longText }>{longText }</div>

Now if user hover over div tag it will show the whole text in something like tooltip.

Happy coding!

Collapse
 
ademola_isr profile image
ADEMOLA OGUNMOKUN

Thank you