1.0.4 • Published 4 years ago

react-native-textarea v1.0.4

Weekly downloads
570
License
MIT
Repository
github
Last release
4 years ago

English | 简体中文

react-native-textarea

npm package npm downloads build

React Native textarea component

Example

npm.io npm.io

Installation

  1. Install package via npm:
$ npm install --save react-native-textarea
  1. Include the library in your code:
import Textarea from 'react-native-textarea';
  1. Use the component:
...
<View style={styles.container}>
  <Textarea
    containerStyle={styles.textareaContainer}
    style={styles.textarea}
    onChangeText={this.onChange}
    defaultValue={this.state.text}
    maxLength={120}
    placeholder={'好玩有趣的,大家同乐,伤感忧闷的,大家同哭。。。'}
    placeholderTextColor={'#c7c7c7'}
    underlineColorAndroid={'transparent'}
  />
</View>
...

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 30,
    justifyContent: 'center',
    alignItems: 'center',
  },
  textareaContainer: {
    height: 180,
    padding: 5,
    backgroundColor: '#F5FCFF',
  },
  textarea: {
    textAlignVertical: 'top',  // hack android
    height: 170,
    fontSize: 14,
    color: '#333',
  },
});

API

Textarea

PropertiesDescritionTypeDefault
maxLengthlimits the maximum number of characters that can be enterednumber0
containerStylecustom styleObject-

More available Textarea API can be found at react-native TextInput