Giter Club home page Giter Club logo

react-native-keyboard-adaptable-view's Introduction

React Native Keyboard Adaptable View

A component that adapt to keyboard and automatically scrolls to focused TextInput or custom text input component. It works on both platforms.

license Version npm GitHub issues

GitHub followers GitHub stars


KeyboardAdaptableView example app.

Features

  • Adapt using autoscroll
  • extraHeight prop to adjust the height of the keyboard

Installation

yarn add react-native-keyboard-adaptable-view or npm install --save react-native-keyboard-adaptable-view

Usage

  1. Import the KeyboardAdaptableView from react-native-keyboard-adaptable-view and wrap your content inside of it.
import KeyboardAdaptableView from "react-native-keyboard-adaptable-view";
...

render() {
    return (
      <KeyboardAdaptableView>
        //...content
      </KeyboardAdaptableView>
    );
  }

...
  1. Add 'adaptKeyboard' prop to components TextInput or custom text input component to active the autoscroll adaptation.
...
  <TextInput adaptKeyboard />
...

OBS: If you are working with a custom text input component, ensure to deal with onFocus, onLayout and forwardRef props inside of it, passing to TextInput of RN.

Props

All the ScrollView props will be accepted, and also:

Name Description Type Required Default Value
extraHeight Add extra height to keyboard view Number 15

Example

import KeyboardAdaptableView from "react-native-keyboard-adaptable-view";

render() {
    return (
      <KeyboardAdaptableView style={styles.container}> //<-- Wrap content with KeyboardAdaptableView
        <Title
          text={"KeyboardAdaptableView"}
        />

        <Text style={styles.title}>Title1</Text>
        <TextInput
          adaptKeyboard //<-- Add 'adaptKeyboard' prop to TextInput or or custom text input component.
          onChangeText={this.onChangeText}
          placeholder={"TextInput1"}
        />

        <Text style={styles.title}>Title2</Text>
        <TextInput
          adaptKeyboard //<-- Add 'adaptKeyboard' prop to TextInput or or custom text input component.
          onChangeText={this.onChangeText}
          placeholder={"TextInput2"}
        />

        <Text style={styles.title}>Title3</Text>
        <MyCustomInput
          adaptKeyboard //<-- Add 'adaptKeyboard' prop to TextInput or or custom text input component.
          onChangeText={this.onChangeText}
          placeholder={"TextInput3"}
        />

        <Button
          iconName={"check"}
          text={"Finish"}
          onPress={this.onButtonPress}
        />
        </KeyboardAdaptableView> //<-- Wrap content with KeyboardAdaptableView
    );
  }

Author

Fabio Freitas

License

MIT

react-native-keyboard-adaptable-view's People

Contributors

fabio-alss-freitas avatar

Watchers

 avatar

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.