Git Product home page Git Product logo

react-native-textarea's Introduction

English | 简体中文

react-native-textarea

npm package npm downloads build

React Native textarea component

Example

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

Properties Descrition Type Default
maxLength limits the maximum number of characters that can be entered number 0
containerStyle custom style Object -

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

react-native-textarea's People

Contributors

gabrieldonadel avatar kimihiro64 avatar skhetcho avatar xinlc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-textarea's Issues

Add a reference to the TextInput component

This is more of a suggestion but came up as an error. The focus() function cannot call the ref for <Textarea> because the component <Textarea> does not have ref setup.
Example:
_handleFieldFocus = (field) => { this.refs[field].focus(); }

render() { return( <Textarea ref="textarea" ... ... /> ... ... <TouchableOpacity onPress(this._handleFieldFocus.bind(this, 'textarea') ) }

This would result in an error

Solution:
within Textarea.js pass ref="textarea"

so the function _handleFieldFocus can call
this.refs[field].refs.textarea.focus();

set count

How can I set the character count directly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.