Skip to content

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

License

Notifications You must be signed in to change notification settings

ambistudio/react-native-spacer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
animationDuration number 300 Duration of the view animation

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

IV. Todo

  • Create tests

V. Changes

  • v1.7.0: Fix measureInWindow not found for latest RN version (thanks @kristerkari)

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •