useKeyboard
React Native software keyboard observer tracking height, visibility, and dismissal.
v0.1.1NativeWindStyleSheetiOSAndroidExpo Go
Installation
npx nativra-cli add use-keyboardWrites use-keyboard.ts to hooks, rewrites imports to your aliases and records hashes in nativra.lock.json. Existing files are never overwritten without asking.
Want to try it first? Open it in the playground: a real React Native project in your browser, with this item installed by the CLI.
Usage
The useKeyboard hook subscribes to native software keyboard events on iOS and Android, providing live visibility state, current keyboard height in points, and a convenient dismiss() method.
Installation
npx nativra add use-keyboardUsage
import { View, Text, TextInput, Button } from "react-native";
import { useKeyboard } from "@/hooks/use-keyboard";
export function FormWithKeyboard() {
const { isVisible, keyboardHeight, dismiss } = useKeyboard();
return (
<View className="p-4 gap-3">
<TextInput placeholder="Tap to open keyboard" className="border p-3 rounded" />
<Text>Keyboard is {isVisible ? `Open (${keyboardHeight}px)` : "Closed"}</Text>
{isVisible && <Button title="Dismiss" onPress={dismiss} />}
</View>
);
}Source
Exactly what the CLI writes, before your import aliases are applied.