Skip to content

Getting Started

  • 📱 Built specifically for React Native/Expo
  • 🎨 Fully customizable styling with render props ( supports nativewind )
  • 📋 Four copy paste styles (Apple, Stripe, Revolt, Dashed)
  • 🧪 100% test coverage
  • 🔄 Easily animated with react-native-reanimated
  • 🌐 Web support with using otp-input
npm install input-otp-native

We create a few examples that you can copy paste and use in your project.

PropTypeDefaultDescription
maxLengthnumberRequiredNumber of OTP digits
render(props: RenderProps) => ReactNodeRequiredRender function for OTP slots
valuestringundefinedControlled value of the input
onChange(value: string) => voidundefinedCallback when value changes
onComplete(value: string) => voidundefinedCallback when all digits are filled
containerStyleViewStyleundefinedStyle for the container
patternstringundefinedRegex pattern for input validation
textAlign’left’ | ‘center’ | ‘right''left’Text alignment within input
pasteTransformer(pasted: string) => stringundefinedTransform pasted text
PropTypeDescription
slotsSlotProps[]Array of slot objects to render
isFocusedbooleanWhether the input is focused
PropTypeDescription
charstring | nullCharacter in the slot
isActivebooleanWhether the slot is active
hasFakeCaretbooleanWhether to show fake caret
placeholderCharstring | nullPlaceholder character

The library is mainly inspired by otp-input and has a similar API, so we recommend using it on the web.

We can easily create the same component for web and create a new file for it (example/src/examples/apple.web.tsx)

See the contributing guide to learn how to contribute to the repository and the development workflow.

MIT