# react-native-keyboard-moving-view

> Out-of-the-box alternative to KeyboardAvoidingView, that provides identical behavior on both iOS and Android, with more extra features

Latest version **0.1.3** (published 2023-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-keyboard-moving-view
pnpm add react-native-keyboard-moving-view
yarn add react-native-keyboard-moving-view
bun add react-native-keyboard-moving-view
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2023-12-16 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18.0.0 |
| Dependencies | 0 |
| Unpacked size | 76.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | yazan |
| Maintainers | ykhateeb |
| Keywords | react-native, ios, android, keyboard |

## Links

- npm: https://www.npmjs.com/package/react-native-keyboard-moving-view
- Repository: https://github.com/ykhateeb/react-native-keyboard-moving-view
- Homepage: https://github.com/ykhateeb/react-native-keyboard-moving-view#readme
- Issues: https://github.com/ykhateeb/react-native-keyboard-moving-view/issues
- npm.io page: https://npm.io/package/react-native-keyboard-moving-view

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2023-12-16
- 0.1.2 — 2023-12-14
- 0.1.1 — 2023-12-12
- 0.1.0 — 2023-12-12

## README

# React Native keyboard Moving View

[![npm](https://img.shields.io/npm/v/react-native-keyboard-moving-view)](https://www.npmjs.com/package/react-native-keyboard-moving-view)
[![npm](https://img.shields.io/npm/dw/react-native-keyboard-moving-view)](https://www.npmjs.com/package/react-native-keyboard-moving-view)
![GitHub](https://img.shields.io/github/license/ykhateeb/react-native-keyboard-moving-view)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ykhateeb/react-native-keyboard-moving-view/ci.yml)](https://github.com/ykhateeb/react-native-keyboard-moving-view/actions/workflows/ci.yml)

Out-of-the-box alternative to [KeyboardAvoidingView](https://reactnative.dev/docs/keyboardavoidingview), that provides identical behavior on both iOS and Android, with more extra features.

## Demonstration

### IOS

|                         Padding                          |                         Position                          |
| :------------------------------------------------------: | :-------------------------------------------------------: |
| <img src="assets/ios-padding.gif?raw=true" width="270"/> | <img src="assets/ios-position.gif?raw=true" width="270"/> |

### Android

|                           Padding                            |                           Position                            |
| :----------------------------------------------------------: | :-----------------------------------------------------------: |
| <img src="assets/android-padding.gif?raw=true" width="270"/> | <img src="assets/android-position.gif?raw=true" width="270"/> |

## Installation

```sh
yarn add react-native-keyboard-moving-view
# OR
npm install react-native-keyboard-moving-view
```

#### IOS

```sh
cd ios && pod install
```

## Usage

```js
import React from 'react';
import { SafeAreaView, TextInput, StyleSheet } from 'react-native';
import { KeyboardMovingView } from 'react-native-keyboard-moving-view';

export default function App() {
  return (
    <SafeAreaView style={styles.safeAreaView}>
      <KeyboardMovingView
        style={styles.keyboardMovingView}
        behavior="position"
        extraHeight={25}
      >
        <TextInput style={styles.textInput} placeholder="Start typing" />
      </KeyboardMovingView>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  safeAreaView: { flex: 1 },
  keyboardMovingView: { flex: 1 },
  textInput: {
    fontSize: 17,
    height: 60,
    width: '100%',
    backgroundColor: '#EFEEEE',
    borderRadius: 5,
    paddingHorizontal: 15,
    marginTop: 'auto',
  },
});
```

Note: if you are using `SafeAreaView` component make sure to wrap it around the `KeyboardMovingView` component to work as expected in IOS like in the example above.

---

## Props

| Name                 | Type                    | Default | Description                                                                                                        |
| -------------------- | ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------ |
| `behavior`           | `padding` OR `position` | `null`  | Determines the behavior of the component when the keyboard is shown                                                |
| `extraHeight`        | `number`                | `0`     | Extra height between the keyboard and focused input(in `position` behavior) OR the content (in `padding` behavior) |
| `onKeyboardWillShow` | `() => void`            | `null`  | Called when the keyboard is about to be shown                                                                      |
| `onKeyboardWillHide` | `() => void`            | `null`  | Called when the keyboard is about to be hidden                                                                     |
| `onKeyboardDidShow`  | `() => void`            | `null`  | Called when the keyboard is shown                                                                                  |
| `onKeyboardDidHide`  | `() => void`            | `null`  | Called when the keyboard is hidden                                                                                 |

---
_Source: https://npm.io/package/react-native-keyboard-moving-view · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
