@mloureiro/react-native-expandable-text
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

React Native Expandable Text

NPM Version License

Travis CI Codacy Badge Codacy Badge

Introduction

ExpandableText React Native component which allows to collapse and expand text. This was built to be very flexible but still lightweight.

component at work example

There are already a few projects with the same propose, so why another one?

  • animated
  • not opionated
    • some of other implementations already have the text in place,
    • force the touchable render to be right after the text
  • full control
    • provides control API so that you use as you wish
  • works with typography:
    • it allows to use your own text components implementation (instead of forcing to style the ExpandableText component)
  • simply works:
    • it works with any level of nested text components
    • it takes the styling into account when measuring

Installation

npm install --save @mloureiro/react-native-expandable-text

or

yarn add @mloureiro/react-native-expandable-text

Usage

An example can be found here.

API:

interface Props {
  children: string | Text
  duration?: number
  easing?: EasingMode
  controller?: (ref: ExpandableTextInterface) => void
  numberOfLines: number
  onReady?: (prop: { isCollapsible: boolean }) => void
}

interface ExpandableTextInterface {
  collapse(): void
  expand(): void
  isCollapsed(): boolean
  isCollapsible(): boolean
  toggle(): void
}

For the available easing modes, there's the documentation on the react-native-collapsible package.

Package Sidebar

Install

npm i @mloureiro/react-native-expandable-text

Weekly Downloads

0

Version

0.2.3

License

ISC

Unpacked Size

1.72 MB

Total Files

22

Last publish

Collaborators

  • mloureiro