jmmendivil / react-native-spacer

A react-native component wrapper that avoiding keyboard when it displayed, support 'absolute' or 'fix' style position

Home Page:https://ambistudio.github.io/react-native-spacer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Native Spacer

NPM badge NPM badge

A view wrapper that will float above the keyboard when it displayed

Technically, it uses Animated.View and will animate a translateY value to avoid the keyboard. KeyboardAvodingView is highly recommended. But in some rare case when KeyboardAvodingView not working, try this Spacer.

Demo

See demo on Expo Snack

Demo

I. Installation

npm install --save react-native-spacer

II. How to use

Class Spacer is a wrapper using Animated.View. For usage, see official documentation Animated and View

1. Import library

import Spacer from 'react-native-spacer';

2. Wrap component into Spacer

<Spacer spaceMargin={20}>
    {/* Components that need to float when keyboard showing */}
</Spacer>

III. Properties

Property Name Type Default Value Definition
spaceMargin number 0 Component's margin above the keyboard when it displayed
enabled bool true Set to false to disable Spacer
backgroundColor string #fffffff7 Spacer component background color

Feel free to have any question, file an issue, or contributing to the module.

IV. Todo

  • Create tests

About

A react-native component wrapper that avoiding keyboard when it displayed, support 'absolute' or 'fix' style position

https://ambistudio.github.io/react-native-spacer/

License:MIT License


Languages

Language:JavaScript 100.0%