Skip to main content

CollapseText -Text folding component

Effect demonstration

1. Default effect

const text = `Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book. It usually begins with:
“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.”`;

<CollapseText text={text} defaultNumberOfLines={3} lineHeight={px(20)} />;
collapseText-ios1.gif

2. Custom style

const text = `Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book. It usually begins with:
“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.”`;

<CollapseText
text={text}
defaultNumberOfLines={3}
lineHeight={px(20)}
textStyle={{ color: 'red', fontSize: px(16) }}
textContainerStyle={{ marginHorizontal: px(10) }}
expandStyle={{ color: 'green', fontSize: px(16) }}
/>;
collapseText-ios2.gif

API

PropertiesRequiredDescriptionTypeDefault Value
texttruetextstring
defaultNumberOfLinesfalseDefault number of displayed linesnumber2
lineHeightfalseThe height of each line of textnumber18
textStylefalsetext styleTextStyle
textContainerStylefalseText container styleViewStyle
expandTextfalseText when expandedstringexpand
unExpandTextfalseText when collapsedstringCollapse
expandStylefalseExpand/collapse text styleTextStyle
activeOpacityfalseOpacity when pressednumber0.6