$ git show keyboard-avoid
Keyboard-aware input bar
A chat input bar that rides up with the keyboard frame by frame instead of jumping when it opens.
// Reanimated 4 deprecates useAnimatedKeyboard; react-native-keyboard-controller gives the same frame-by-frame values
import { KeyboardProvider, useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
// Wrap the app once: <KeyboardProvider><App /></KeyboardProvider>
const { height, progress } = useReanimatedKeyboardAnimation(); // height is negative while open
const { bottom } = useSafeAreaInsets();
const bar = useAnimatedStyle(() => ({
// Same inset trick: move by the keyboard height minus what the safe area already covers
transform: [{ translateY: Math.min(height.value + bottom * progress.value, 0) }],
}));
<View style={{ flex: 1 }}>
<FlatList inverted data={messages} renderItem={renderMessage} />
<Animated.View style={[styles.inputBar, { paddingBottom: bottom }, bar]}>
<TextInput placeholder="Message" style={styles.input} />
<SendButton />
</Animated.View>
</View>
// The library also ships KeyboardStickyView, which does this in one component