In this image i want to display the asset name up to 20 characters for example aaaaaaaaaaaa.....
<td className="truncateText">{assetName}</td>
i am using css
.truncateText{
text-overflow: ellipsis;
max-width: 0px;
overflow: hidden;
white-space: nowrap;
}
You can use substr()
method to for it:
<td title={assetName} className="truncateText">
{assetName.length < 20 ? assetName : assetName.substr(0, 20) + "..."}
</td>
Example: Expo Snack