Skip to content

danielshin/react-native-material-textfield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-material-textfield

npm license

Material texfield with consistent behaviour on iOS and Android

Example

Features

  • Material design guidelines compliance
  • Consistent look and feel on iOS and Android
  • Animated state transitions (normal, focused and errored)
  • Customizable font size, colors and animation duration
  • Disabled state (with dotted underline)
  • Helper text
  • Character counter
  • Multiline text input
  • Pure javascript implementation

Installation

npm install --save react-native-material-textfield

Usage

import React, { Component } from 'react';
import { TextField } from 'react-native-material-textfield';

class Example extends Component {
  state = {
    phone: '',
  };

  render() {
    let { phone } = this.state;

    return (
      <TextField
        label='Phone number'
        value={phone}
        onChangeText={ (phone) => this.setState({ phone }) }
      />
    );
  }
}

Properties

  • textColor - Text input color (default: rgba(0, 0, 0, .87))

  • fontSize - Text input font size

  • tintColor - Text field accent color (default: rgb(0, 145, 234))

  • baseColor - Text field base color (default: rgba(0, 0, 0, .38))

  • label - Text field label text

  • title - Text field helper text

  • error - Text field error text

  • errorColor - Text field color for errored state (default: rgb(213, 0, 0))

  • animationDuration - Text field animation duration in ms (default: 225)

  • characterRestriction - Text field soft limit for character counter

  • disabled - Text field availability (default: false)

  • editable - Text field text can be edited (default: true)

  • multiline - Text filed multiline input (default: false)

  • onChangeText - Change text callback

  • onFocus - Focus callback

  • onBlur - Blur callback

Other TextInput properties will also work

Methods

  • focus() - Acquire focus
  • blur() - Release focus
  • clear() - Clear text field
  • value() - Get current value
  • isFocused() - Get current focus state
  • isRestricted() - Get current restriction state

Example

git clone https://github.com/n4kz/react-native-material-textfield.git
cd react-native-material-textfield/example
npm install
react-native run-ios # or run-android

Copyright and License

BSD License

Copyright 2017 Alexander Nazarov. All rights reserved.

About

Material textfield

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 76.8%
  • Objective-C 13.7%
  • Python 5.1%
  • Java 4.4%