This Ember addon provides a component for truncating/clamping text.
- Note: This component currently does not support block form.
npm install ember-line-clamp
Demo application here
To get started, place the line-clamp
component in one of your templates and provide a string to the text
attribute. The line-clamp
component supports other attributes, for more details you can always look at the source code.
The text attribute is not required but would be nice to truncate something.
Default:
This attribute allows you to set the number of lines to clamp the text.
Default: 3
This attribute allows user to prevent stripping text of <br>
tags when clamping.
Default: true
The characters/string to be used as the overflow element.
Default: ...
Line clamp is not always interactive, in fact if you use -webkit-line-clamp
there is not interqaction enabled. This attribute allows you to enable see more/see less functionality and overpowers showMoreButton
and showLessButton
when false
. In cases where you do not want any interaction -webkit-line-clamp
is used in the background to save work.
Default: true
Some users for some unknown reason might like to disable the native CSS solution when available, we want to keep them happy.
Default: false
Some users might not like our style for the component, and they would like to do some fancy stuff. You can use this attribute to control truncation from outside the component and have a button that controls the truncation.
Default: true
This attribute enables/disables 'See More' functionality
Default: true
This attribute enables/disables 'See Less' functionality
Default: true
This component should work in any language, hence this attribute allows you to set the text for the 'See More' button
Default: See More
This component should work in any language, hence this attribute allows you to set the text for the 'See Less' button
Default: See Less
This attribuet allows you to pass an action/closure to trigger when text is expanded
This attribuet allows you to pass an action/closure to trigger when text is collapsed
This attribuet allows you to pass an action/closure to trigger everytime the text goes through the truncation procedure, receives a boolean to determine if text was truncated
- tests
- demo page
- support block form
- CSS Line Clamping article
- @nilsynils for his Medium Post
- @One-com for a inspiration