DEV Community

Cover image for readmore-lines: Read More/Less by Line Count (JS Library)
jQueryScript
jQueryScript

Posted on

readmore-lines: Read More/Less by Line Count (JS Library)

ReadMore Lines: a lightweight vanilla JavaScript library for line-based text truncation with a read more / read less toggle.

Key features:

  • Truncates by rendered line count using CSS -webkit-line-clamp
  • Accessible toggle button with ARIA attributes and keyboard support
  • WeakMap instance tracking for safe cleanup and re-initialization
  • CSS custom properties for full button theming
  • ~2.5KB minified, no dependencies

Great for blog cards, product pages, and comment threads where text length varies.

👉 Blog Post

👉 GitHub Repo

👉 Live Demo

Top comments (0)