An open API service indexing awesome lists of open source software.

https://github.com/pakenfit/react-native-pin-input

React Native Pin Input made easy🔥
https://github.com/pakenfit/react-native-pin-input

otp otp-verification pin-input react-native textinput

Last synced: 10 months ago
JSON representation

React Native Pin Input made easy🔥

Awesome Lists containing this project

README

          

# @pakenfit/react-native-pin-input

Phone Pin Input for React Native.




## Installation

```sh
npm install @pakenfit/react-native-pin-input --save
```

Or

```sh
yarn add @pakenfit/react-native-pin-input
```

#### Dependencies
This library needs these dependencies to be installed in your project before you can use it:

```sh
npm install expo-clipboard --save
```

Or

```sh
yarn add expo-clipboard
```
#### Using Bare React Native ?
For `expo-clipboard` to work you need to follow [these additional steps to install expo modules.](https://docs.expo.dev/bare/installing-expo-modules/)

## Features

- Fully customizable
- OTP autofill support (both `Android` and `iOS`, not tested on `web` should work as well)
- Compatible with Expo
- Written in Typescript

---

## Usage

```js
import { Button, StyleSheet, View } from 'react-native';
import { PinInput, PinInputRef } from '@pakenfit/react-native-pin-input';

export default function App() {
const ref = React.useRef(null);

return (

console.log(otp)} autoFocus ref={ref} />
ref.current?.clear()} />

);
}
```
---
## Props

### `length`
The number of pin inputs to display. `Default: 4`.

---

### `onFillEnded = (opt: string) => void`
The callback function with the final OTP when finish filling the inputs.

### `inputProps`
The props for each TextInput.

---

### `inputStyle`
The style applied to each `TextInput`.

---

### `containerProps`
The props for the `View` container.

---

### `containerStyle`
The style applied to the `View` container.

---

### `autoFocus`
Should autoFocus the first `input` element.

## API
The PinInput component provides the following methods through the PinInputRef:

- `clear()`: clear all the pin inputs

## Types

### PinInputRef
The `PinInputRef` type represents the reference to the PinInput component, allowing access to its methods. It has the only method: `clear()` see above.

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)