### Basic OTP Input Setup Source: https://github.com/anday013/react-native-otp-entry/blob/main/_autodocs/api-reference/OtpInput.md A basic example of setting up the OtpInput component with a specified number of digits and handling text changes and completion. ```typescript import { OtpInput } from "react-native-otp-entry"; import { useState } from "react"; import { View, Text } from "react-native"; export function BasicOtpScreen() { const [otp, setOtp] = useState(""); return ( Enter 6-digit OTP setOtp(text)} onFilled={(text) => console.log(`OTP filled: ${text}`)} /> Current OTP: {otp} ); } ``` -------------------------------- ### Install react-native-otp-entry Source: https://github.com/anday013/react-native-otp-entry/blob/main/README.MD Install the react-native-otp-entry package using npm or yarn. ```bash npm install react-native-otp-entry # or yarn add react-native-otp-entry ``` -------------------------------- ### Install react-native-otp-entry Source: https://github.com/anday013/react-native-otp-entry/blob/main/_autodocs/README.md Install the library using npm. It has zero external dependencies beyond React and React Native. ```bash npm install react-native-otp-entry ``` -------------------------------- ### Consumer Import Example Source: https://github.com/anday013/react-native-otp-entry/blob/main/_autodocs/MODULE_STRUCTURE.md Shows how consumers should import components and types from the library's primary entry point. ```typescript import { OtpInput, OtpInputProps, Theme, OtpInputRef } from "react-native-otp-entry"; ``` -------------------------------- ### Styled Component Example Source: https://github.com/anday013/react-native-otp-entry/blob/main/_autodocs/README.md Demonstrates how to apply custom styling to the OtpInput component using the theme prop. ```typescript ``` -------------------------------- ### Complete OTP Input Configuration Source: https://github.com/anday013/react-native-otp-entry/blob/main/_autodocs/configuration.md This example demonstrates a comprehensive configuration of the OtpInput component, including styling, input type, focus behavior, and button controls for clearing and enabling/disabling the input. ```typescript import { OtpInput } from "react-native-otp-entry"; import { useRef, useState } from "react"; import { View, StyleSheet, Button } from "react-native"; const styles = StyleSheet.create({ container: { padding: 20, backgroundColor: "#f9f9f9", }, otpContainer: { gap: 12, justifyContent: "center", }, pinCodeContainer: { borderWidth: 2, borderColor: "#e0e0e0", borderRadius: 10, height: 55, width: 45, backgroundColor: "#fff", }, focusedPinCodeContainer: { borderColor: "#2196F3", backgroundColor: "#e3f2fd", }, filledPinCodeContainer: { borderColor: "#4CAF50", }, disabledPinCodeContainer: { backgroundColor: "#f0f0f0", opacity: 0.5, }, pinCodeText: { fontSize: 22, fontWeight: "600", color: "#333", }, placeholderText: { fontSize: 18, color: "#bbb", }, focusStick: { width: 3, height: 32, }, }); export function CompleteOtpConfiguration() { const otpRef = useRef(null); const [otp, setOtp] = useState(""); const [isDisabled, setIsDisabled] = useState(false); return ( setOtp(text)} onFilled={(text) => console.log(`OTP: ${text}`)} onFocus={() => console.log("Focused")} onBlur={() => console.log("Blurred")} theme={{ containerStyle: styles.otpContainer, pinCodeContainerStyle: styles.pinCodeContainer, focusedPinCodeContainerStyle: styles.focusedPinCodeContainer, filledPinCodeContainerStyle: styles.filledPinCodeContainer, disabledPinCodeContainerStyle: styles.disabledPinCodeContainer, pinCodeTextStyle: styles.pinCodeText, placeholderTextStyle: styles.placeholderText, focusStickStyle: styles.focusStick, }} textInputProps={{ accessibilityLabel: "One-Time Password", testID: "otp-input", }} textProps={{ accessibilityRole: "text", accessibilityLabel: "OTP digit", allowFontScaling: false, }} />