1.0.0 • Published 3 years ago

@jereztech/react-native-collapsible-text v1.0.0

Weekly downloads
-
License
GPLv3
Repository
github
Last release
3 years ago

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.

License-GPLv3 contributions-welcome

Example

Installation

npm i @jereztech/react-native-collapsible-text --save

Props

PropTypeRequiredNote
textstringyeslong text that can be truncated according to numberOfLines
textStyleobjectnostyle applied to text
numberOfLinesnumberyesthe number of lines of the truncated text
readMoreLabelstringnothe Read More localized label
readLessLabelstringnothe Read Less localized label
readMoreStyleobjectnostyle 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',
  },
});