1.3.0 • Published 3 years ago

react-native-see-more-inline v1.3.0

Weekly downloads
171
License
MIT
Repository
github
Last release
3 years ago

react-native-see-more-inline

Show a "read more", "see more", "read less", "see less" inline with your text in React Native

My motivation of building this was that I couldn't find any library/implementation that would place the "see more" link inline with the text. All the other implementations I found would place the link under the text. This package uses text width, and using a simple binary search it (almost) accurately calculates where it should place the "see more" link.

npm.io npm.io npm.io

Installing the package

  1. Install react-native-text-size v4.0.0-rc.1
  2. yarn add react-native-see-more-inline or npm install --save react-native-see-more-inline

Note: This package will not work with expo managed projects. The dependency react-native-text-size links natively. Till we have a dependency on this package to measure the text width, this limitation will remain.

Usage

import SeeMore from 'react-native-see-more-inline';

<SeeMore numberOfLines={2}>
  {VERY_LARGE_TEXT}
</SeeMore>

<SeeMore numberOfLines={2} linkStyle={{ fontWeight: '500' }}>
  {VERY_LARGE_TEXT}
</SeeMore>

Props

PropDefault ValueRequiredType
numberOfLines-yesnumber
linkColor'#2E75F0'nostring
linkPressedColor'#163772'nostring
linkStyleundefinednoarray/object
seeMoreText'see more'nostring
seeLessText'see less'nostring
style{ fontFamily: undefined, fontSize: 14, fontWeight: '300' }noarray/object

Running the example

  1. cd example
  2. yarn install
  3. Terminal 1 - yarn start
  4. Terminal 2 - yarn run wml
  5. Terminal 3 - yarn run ios / yarn run android
1.3.0

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago