Phone Pin Input for React Native.
npm install @pakenfit/react-native-pin-input --save
Or
yarn add @pakenfit/react-native-pin-input
This library needs these dependencies to be installed in your project before you can use it:
npm install expo-clipboard --save
Or
yarn add expo-clipboard
For expo-clipboard
to work you need to follow these additional steps to install expo modules.
- Fully customizable
- OTP autofill support (both
Android
andiOS
, not tested onweb
should work as well) - Compatible with Expo
- Written in Typescript
import { Button, StyleSheet, View } from 'react-native';
import { PinInput, PinInputRef } from '@pakenfit/react-native-pin-input';
export default function App() {
const ref = React.useRef<PinInputRef>(null);
return (
<View style={styles.container}>
<PinInput onFillEnded={(otp) => console.log(otp)} autoFocus ref={ref} />
<Button title="Clear all" onPress={() => ref.current?.clear()} />
</View>
);
}
The number of pin inputs to display. Default: 4
.
The callback function with the final OTP when finish filling the inputs.
The props for each TextInput.
The style applied to each TextInput
.
The props for the View
container.
The style applied to the View
container.
Should autoFocus the first input
element.
The PinInput component provides the following methods through the PinInputRef:
clear()
: clear all the pin inputs
The PinInputRef
type represents the reference to the PinInput component, allowing access to its methods. It has the only method: clear()
see above.
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library