Giter Site home page Giter Site logo

react-native-floating-labels's Introduction

react-native-floating-labels Build Status npm version MIT licensed Code Climate

A <FloatingLabel> component for react-native. This is still very much a work in progress and only handles the simplest of cases, ideas and contributions are very welcome.

Demo

Add it to your project

  1. Run npm install react-native-floating-labels --save
  2. var FloatingLabel = require('react-native-floating-labels');

Usage

'use strict';

var React = require('react-native');

var FloatingLabel = require('react-native-floating-labels');

var {
  AppRegistry,
  StyleSheet,
  View,
} = React;

class form extends React.Component {

  constructor(props, context) {
    super(props, context);

    this.state = {
      dirty: false,
    };
  }

  onBlur() {
    console.log('#####: onBlur');
  }

  render() {
    return (
      <View style={styles.container}>
        <FloatingLabel 
            labelStyle={styles.labelInput}
            inputStyle={styles.input}
            style={styles.formInput}
            value='[email protected]'
            onBlur={this.onBlur}
          >Email</FloatingLabel>
        <FloatingLabel 
            labelStyle={styles.labelInput}
            inputStyle={styles.input}

            style={styles.formInput}
          >First Name</FloatingLabel>
        <FloatingLabel
            labelStyle={styles.labelInput}
            inputStyle={styles.input}
            style={styles.formInput}
          >Last Name</FloatingLabel>
      </View>
    );
  }
};

var styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 65,
    backgroundColor: 'white',
  },
  labelInput: {
    color: '#673AB7',
  },
  formInput: {    
    borderBottomWidth: 1.5, 
    marginLeft: 20,
    borderColor: '#333',       
  },
  input: {
    borderWidth: 0
  }
});

AppRegistry.registerComponent('form', () => form);


Additional Props:

FloatingLabel is just like any TextInput. It supports the below mentioned events handlers:

Following properties of TextInput are supported:

- autoCapitalize
- autoCorrect
- autoFocus
- bufferDelay
- clearButtonMode
- clearTextOnFocus
- controlled
- editable
- enablesReturnKeyAutomatically
- keyboardType
- multiline
- password
- returnKeyType
- selectTextOnFocus
- selectionState
- style
- testID
- value

Following events are supported:

- onBlur
- onChange
- onChangeText
- onEndEditing
- onFocus
- onSubmitEditing

MIT Licensed

react-native-floating-labels's People

Contributors

dtest000 avatar ejsp92 avatar karaxuna avatar mayank-patel avatar murtraja avatar mvayngrib avatar nairihar avatar pgmemk avatar tomsapps avatar victorpiccoli 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-floating-labels's Issues

Not able to change cursor color

Hello Mayank,
Thanks for the library. I noticed that one cannot change the cursor color by using the selectionColor prop provided by TextInput. I have simply added that prop in #35

SCrollview not works when user scrolls

Hello, I've several floating labels in a view inside the Scrollview. The issue I face that the scrollview not works if the user scrolls while focusing a floating label. However the scrolls works fine in TextInput even if the focus is on it but not working in floating label. Could you please let me know how can I sort this issue out. As I've too many floating labels on page, so whenever user try to scroll the page putting finger on the label, the text inside that scrolls a little,but not the complete page

Floating label doesn't work properly with events

I am having issue with FloatingLabel, whenever I use onChangeText event, my floating label floats at his starting position when I write something. But it works perfectly when I don't use onChangeText , onBlur and other events. Please help!

    <FloatingLabel
              labelStyle={Styles.labelInput}
              inputStyle={Styles.input}
              style={Styles.formInput}
              underlineColorAndroid="transparent"
              secureTextEntry={true}
              onChangeText={(password) => this.setState({password})}
          >Password</FloatingLabel>

Styles:

 labelInput: {
    fontSize: 16,
  },

  formInput: {
    borderBottomWidth: 1,
    borderColor: '#e6e6e6',
  },
  input: {
    fontSize: 14,
    borderWidth: 0
  }

Default border bottom is appearing in android.

When the app is initialized, each time it is showing default android green color border at bottom of the text input.
screen shot 2017-09-08 at 4 34 17 pm

But, if I am reloading the app, it's working fine as the style I wrote for the input.

unable to resolve module 'create-react-class'

Hi,
I installed your package using npm install react-native-floating-labels --save

but my build fails and the error is unable to resolve module 'create-react-class in react-native-floating-labels\\index.js.

any fix for this?

Remove or update dependence on ViewPropTypes

ViewPropTypes has been deprecated for React Native 0.68.0. They need to be imported from the 'deprecated-react-native-prop-types' library.

Otherwise there is a runtime error.

ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'.

secure text entry?

Does this support secure text entry?
edit: sorry didn't see the password input field #mybad

Property "password" does not works on android

React Native 0.39.2
Android 7.1.1 & 6.0.1 & 5.1
IOS 10.2

IOS :
ios

Android :
android

My code

import FloatingLabel from 'react-native-floating-labels';

<FloatingLabel
            labelStyle={styles.labelInput}
            inputStyle={styles.input}
            password={true}
            onChangeText={(e) => EmployerData.password = e.trim().replace('+', encodeURIComponent('+'))}
            style={[styles.formInput, styles.textfieldWithFloatingLabel, { marginTop: mainComponent.state.marginBetweenFields, borderColor: mainComponent.state.underlineColor }]}>Contraseña</FloatingLabel>

This code works properly on IOS but on Android the letters are not hiding,
I had test it on Android 7.1.1 (Nougat), 6.0.1 (Marshmallow), 5.1 (lollipop)

Warning: componentWillReceiveProps has been renamed, and is not recommended for use.

I am getting the following warning.

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: FloatingLabel

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.