Convert Figma logo to code with AI

kirillzyusko logoreact-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android

2,555
109
2,555
48

Top Related Projects

A ScrollView component that handles keyboard appearance and automatically scrolls to focused TextInput.

Plug and play react-native keyboard spacer view.

A <Modal/> component for react-native

Quick Overview

React Native Keyboard Controller is a library that provides advanced keyboard handling capabilities for React Native applications. It offers smooth animations, precise control over keyboard interactions, and support for both iOS and Android platforms.

Pros

  • Seamless integration with React Native projects
  • Provides precise control over keyboard animations and interactions
  • Supports both iOS and Android platforms
  • Offers a wide range of customization options

Cons

  • Requires additional setup and configuration compared to built-in React Native keyboard handling
  • May have a learning curve for developers new to advanced keyboard management
  • Could potentially increase app bundle size
  • Limited documentation for some advanced use cases

Code Examples

  1. Basic usage with a ScrollView:
import { KeyboardController, KeyboardControllerView } from 'react-native-keyboard-controller';

function App() {
  return (
    <KeyboardControllerView>
      <ScrollView>
        {/* Your content here */}
      </ScrollView>
    </KeyboardControllerView>
  );
}
  1. Using the useKeyboardController hook:
import { useKeyboardController } from 'react-native-keyboard-controller';

function MyComponent() {
  const { status, height } = useKeyboardController();

  return (
    <View style={{ paddingBottom: height }}>
      {/* Your content here */}
    </View>
  );
}
  1. Customizing keyboard animation:
import { KeyboardController } from 'react-native-keyboard-controller';

function App() {
  return (
    <KeyboardController
      style={{ flex: 1 }}
      animation="spring"
      springConfig={{ mass: 1, stiffness: 200, damping: 25 }}
    >
      {/* Your content here */}
    </KeyboardController>
  );
}

Getting Started

  1. Install the library:

    npm install react-native-keyboard-controller
    
  2. For iOS, install pods:

    cd ios && pod install
    
  3. Import and use the KeyboardControllerView in your app:

    import { KeyboardControllerView } from 'react-native-keyboard-controller';
    
    function App() {
      return (
        <KeyboardControllerView>
          {/* Your app content */}
        </KeyboardControllerView>
      );
    }
    
  4. For more advanced usage, refer to the library's documentation and examples.

Competitor Comparisons

A ScrollView component that handles keyboard appearance and automatically scrolls to focused TextInput.

Pros of react-native-keyboard-aware-scroll-view

  • Simpler implementation with less configuration required
  • Longer history and more established in the React Native community
  • Works well with ScrollView and FlatList components out of the box

Cons of react-native-keyboard-aware-scroll-view

  • Limited customization options for keyboard behavior
  • May not handle complex layouts or nested scrollable components as effectively
  • Less performant for larger lists or complex UIs

Code Comparison

react-native-keyboard-aware-scroll-view:

import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

<KeyboardAwareScrollView>
  {/* Your content here */}
</KeyboardAwareScrollView>

react-native-keyboard-controller:

import { KeyboardController } from 'react-native-keyboard-controller';

<KeyboardController
  style={styles.container}
  onKeyboardMoved={(height) => console.log(height)}
>
  {/* Your content here */}
</KeyboardController>

The react-native-keyboard-aware-scroll-view offers a simpler API, wrapping content in a scrollable component. In contrast, react-native-keyboard-controller provides more granular control over keyboard interactions and animations, allowing for custom behaviors and more complex layouts. The latter also offers better performance for larger lists and more intricate UIs, but may require more setup and configuration.

Plug and play react-native keyboard spacer view.

Pros of react-native-keyboard-spacer

  • Simpler implementation with fewer dependencies
  • Lightweight and focused on a single task (adjusting view for keyboard)
  • Easier to integrate into existing projects

Cons of react-native-keyboard-spacer

  • Less actively maintained (last update was 3 years ago)
  • Limited functionality compared to react-native-keyboard-controller
  • May not work as well with newer React Native versions

Code Comparison

react-native-keyboard-spacer:

import KeyboardSpacer from 'react-native-keyboard-spacer';

<View>
  <TextInput />
  <KeyboardSpacer />
</View>

react-native-keyboard-controller:

import { KeyboardProvider, KeyboardSpacer } from 'react-native-keyboard-controller';

<KeyboardProvider>
  <View>
    <TextInput />
    <KeyboardSpacer />
  </View>
</KeyboardProvider>

The react-native-keyboard-controller requires wrapping the app with a KeyboardProvider, offering more advanced features but with slightly more setup. The react-native-keyboard-spacer is simpler to implement but provides fewer options for customization and control.

react-native-keyboard-controller offers more features like keyboard animations, insets management, and better TypeScript support. However, it may be overkill for simple projects where only basic keyboard adjustment is needed. react-native-keyboard-spacer is a good choice for straightforward keyboard handling in older projects, but its lack of recent updates may be a concern for long-term maintenance.

A <Modal/> component for react-native

Pros of react-native-modalbox

  • Simpler implementation for basic modal functionality
  • Lightweight and focused on modal-specific features
  • Easier to set up and use for straightforward modal requirements

Cons of react-native-modalbox

  • Less comprehensive keyboard handling capabilities
  • Limited customization options for advanced use cases
  • Fewer features for managing complex modal interactions

Code Comparison

react-native-modalbox:

<Modal style={styles.modal} position={"center"} isOpen={this.state.isOpen}>
  <Text>Basic Modal</Text>
</Modal>

react-native-keyboard-controller:

<KeyboardControllerView>
  <KeyboardAvoidingView>
    <TextInput />
  </KeyboardAvoidingView>
</KeyboardControllerView>

react-native-modalbox focuses on creating and managing modals with a straightforward API, while react-native-keyboard-controller provides more advanced keyboard handling and layout management. The former is better suited for simple modal implementations, while the latter offers more comprehensive control over keyboard interactions and screen layout adjustments.

react-native-keyboard-controller excels in handling complex keyboard-related scenarios, offering features like smooth animations, keyboard-aware scrolling, and precise control over input accessories. It's particularly useful for apps with forms or chat interfaces that require sophisticated keyboard management.

Choose react-native-modalbox for quick and easy modal implementations, and opt for react-native-keyboard-controller when you need advanced keyboard handling and layout control in your React Native application.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

react-native-keyboard-controller

A universal keyboard handling solution for React Native — lightweight, fully customizable, and built for real-world apps. Smooth animations, consistent behavior on both iOS and Android, with a developer-oriented design.

Key features

  • 🧬 Map keyboard movement to animated values
  • 🧪 keyboardWillShow / keyboardWillHide events now available on Android
  • ⚡ Change soft input mode on Android
  • 🚀 Reanimated support
  • 📱 Interactive keyboard dismissing 👆📱
  • 📚 Prebuilt components (KeyboardStickyView, KeyboardAwareScrollView, reworked KeyboardAvoidingView)
  • 📐 KeyboardToolbar with customizable previous, next, and done buttons
  • 🌐 Display anything over the keyboard (without dismissing it) using OverKeyboardView
  • 🎨 Match keyboard background with KeyboardBackgroundView
  • 🧩 Extend keyboard with custom buttons/UI via KeyboardExtender
  • 📝 Easy retrieval of focused input info
  • 🧭 Compatible with any navigation library
  • ✨ More coming soon... stay tuned! 😊

Installation

Check out the installation section of the docs for detailed setup instructions.

Documentation

Full API reference and guides available at:
https://kirillzyusko.github.io/react-native-keyboard-controller/

Contributing

See the contributing guide to learn how to contribute to the repo and development workflow.

License

MIT

NPM DownloadsLast 30 Days