Vue Truncate Collapsed screenshot

Vue Truncate Collapsed

Author Avatar Theme by Kavalcante
Updated: 10 Oct 2020
108 Stars

A simple component that truncates your text and adds a 'Read More/Show Less' clickable.

Overview

The vue-truncate-collapsed component is a clever solution for managing lengthy text in a Vue 2 application. Perfect for situations where space is limited, this component allows users to display a snippet of text with a “Read More” link, which expands to reveal the full text upon clicking. This functionality not only enhances the user experience by providing a clean, organized layout, but it also maintains the aesthetic appeal of your website or application.

Developers will appreciate its straightforward installation and customization options. With just a few lines of code, you can integrate this component into your project, allowing users to toggle between truncated and expanded text seamlessly.

Features

  • Truncation State: The component starts in either expanded or collapsed state based on the truncated boolean option.
  • Custom Text Input: You can provide any string as the text to be truncated, giving you flexibility in content display.
  • Length Control: Set the length option to define how many characters are visible before truncation occurs, tailoring the display to your design needs.
  • Expandable Links: Customize the clamp link to change what users see when the text is truncated, encouraging them to read more.
  • Show Less Option: The less string allows you to modify the link that appears when the text is expanded, providing a user-friendly way to collapse the text again.
  • Text Type: Choose between treating your text as normal text or as raw HTML with the type option for greater control over content formatting.
  • Custom Class Support: You can easily add custom class names to the read more/show less links for consistent styling across your application.
  • Collapsed Text Styling: Use the collapsedTextClass attribute to apply specific styles to the text when it is in a collapsed state, enhancing visual differentiation.