Truncating Text with Read More/Read Less Button

Jay Wen
1 min readMar 30, 2022

When browsing through a website, most people want to get to the meat of the site, especially when they are shopping. This week I had to shorten the collection’s description after 3 lines of text on mobile devices because it was taking way too much space and none of the products showed on the screen on load.

After some googling, I found a “line clamp” property which allows you to truncate after a certain number of lines of text.

The implementation I took was the following:

--

--

Jay Wen

Hey! I’m a full stack software engineer. Here’s where I document my technical learning and any tips/skills I can share as I continue to learn. :)