3.0.1 • Published 4 years ago

vue-truncate-collapsed v3.0.1

Weekly downloads
3,660
License
MIT
Repository
github
Last release
4 years ago

vue-truncate-collapsed

A simple Vue 2 Component that's truncate your text and adds a "Read Me/Show Less" clickable.

Getting Started

NPM

$ npm install vue-truncate-collapsed --save

Clone this repo

Clone or download the component and save in your own project.

Installing

ES6

import truncate from 'vue-truncate-collapsed';

new Vue({
  components: {
    truncate
  }
})

CommonJS

var truncate = require('vue-truncate-collapsed');

new Vue({
  components: {
    'truncate': truncate
  }
})

CDN

<!-- import JavaScript -->
<script src="https://unpkg.com/vue-truncate-collapsed"></script>

USAGE

Text

<truncate clamp="..." :length="90" less="Show Less" text="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam modi consequuntur quis porro explicabo iusto repudiandae odio nobis, assumenda iure totam, eum expedita quae at nostrum excepturi corrupti unde et."></truncate>

Raw HTML

<truncate clamp="..." :length="90" less="Show Less" type="html" text="<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p> Quam modi consequuntur quis porro explicabo iusto repudiandae odio nobis, assumenda iure totam, eum expedita quae at nostrum excepturi corrupti unde et.</p>"></truncate>

Add class to Show More/ Show Less link

<truncate action-class="customClass" clamp="Show more" :length="90" less="Show Less" type="html" text="<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p> Quam modi consequuntur quis porro explicabo iusto repudiandae odio nobis, assumenda iure totam, eum expedita quae at nostrum excepturi corrupti unde et.</p>"></truncate>

Add class to collapsed text

<truncate collapsed-text-class="collapsed" clamp="Show more" :length="90" less="Show Less" type="html" text="<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> <p> Quam modi consequuntur quis porro explicabo iusto repudiandae odio nobis, assumenda iure totam, eum expedita quae at nostrum excepturi corrupti unde et.</p>"></truncate>

Attributes

OptionDefaultTypeDescription
truncatedfalsebooleanThe initial state of the truncation. true is collapsed, false is expanded.
textno default valuestringThe text that will be truncated.
length100numberLength of text after truncate.
clampRead MorestringLink that will be after the text with a link to expand.
lessShow LessstringLink that will be after the text when it's expand, when click text collapses.
typetextstringEither text or html. To change whether to treat the input from text attribute as text or raw HTML.
classempty stringstringTo add a class name to the link that will be after the text is expanded or collapsed.
collapsedTextClass''stringAllows you to add a class to the text when it is collapsed.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

3.0.1

4 years ago

3.0.0

4 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.9.0

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago