rn-keyboard-aware-scrollview
v0.1.2
Published
A drop-in, cross-platform Keyboard Aware ScrollView for React Native that intelligently adjusts the screen position to keep focused TextInput components visible when the keyboard appears. Highly customizable and easy to use.
Readme
rn-keyboard-aware-scrollview
A React Native ScrollView component that automatically scrolls to keep focused TextInput fields visible when the keyboard appears. Supports iOS and Android.
Why
Dealing with keyboards in React Native can be a hassle. When a keyboard appears, it can cover the TextInput field you're trying to edit. This component is a drop-in replacement for the standard ScrollView that seamlessly and automatically scrolls to keep the focused TextInput visible, providing a smooth user experience on both iOS and Android.
Demo
Installation
npm install rn-keyboard-aware-scrollviewUsage
import { TextInput, View } from 'react-native';
import { KeyboardAwareScrollView } from 'rn-keyboard-aware-scrollview';
function MyForm() {
return (
<KeyboardAwareScrollView>
<View>
<TextInput placeholder="Field 1" />
<TextInput placeholder="Field 2" />
<TextInput placeholder="Field 3" />
</View>
</KeyboardAwareScrollView>
);
}Props
| Prop | Type | Default | Description |
| ------------------------------ | -------------------------------------- | --------------------------------------------- | ------------------------------------- |
| extraScrollHeight | number | 30 | Extra padding below the focused input |
| enableOnAndroid | boolean | true | Enable keyboard handling on Android |
| keyboardShouldPersistTaps | 'always' \| 'never' \| 'handled' | 'handled' | Keyboard persistence behavior |
| keyboardDismissMode | 'none' \| 'on-drag' \| 'interactive' | 'interactive' (iOS) / 'on-drag' (Android) | Keyboard dismiss behavior |
| showsVerticalScrollIndicator | boolean | false | Show scroll indicator |
| bounces | boolean | false | Enable bounce effect (iOS) |
| style | StyleProp<ViewStyle> | - | Style for the ScrollView |
| contentContainerStyle | StyleProp<ViewStyle> | - | Style for the content container |
Contributing
License
MIT
Made with create-react-native-library

