1.0.0 • Published 3 years ago
@jereztech/react-native-collapsible-text v1.0.0
react-native-collapsible-text
Truncate text that exceeds a given number of lines. It can be expanded or collapsed by the Read More or Read Less localized buttons.
Installation
npm i @jereztech/react-native-collapsible-text --save
Props
Prop | Type | Required | Note |
---|---|---|---|
text | string | yes | long text that can be truncated according to numberOfLines |
textStyle | object | no | style applied to text |
numberOfLines | number | yes | the number of lines of the truncated text |
readMoreLabel | string | no | the Read More localized label |
readLessLabel | string | no | the Read Less localized label |
readMoreStyle | object | no | style applied to Read More/Less labels |
Usage
import React from 'react';
import { StyleSheet, View } from 'react-native';
import * as CollapsibleText from "@jereztech/react-native-collapsible-text";
export default function App() {
return (
<View style={styles.container}>
<CollapsibleText
numberOfLines={1}
text='Localized And Stylish Text. Lorem ipsum lobortis euismod velit adipiscing aenean justo.'
textStyle={{ color: 'yellow', fontSize: 25 }}
readMoreStyle={{ fontWeight: 'bold', color: 'blue', fontStyle: 'italic', fontSize: 25 }}
readMoreLabel='leer más'
readLessLabel='leer menos'
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
1.0.0
3 years ago