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)