# OTP Input — React Native component for Expo

> Digits pop into cells that size themselves, with SMS autofill and paste.

One-time-code cells that size themselves to fit any width. The active cell glows with a soft focus halo and a blinking caret, digits pop in on a spring, a pasted code fills every cell, errors shake the row and success pulses across the cells with a drawn check.

- Docs: https://expokit.in/docs/components/otp-input
- Tier: Free
- Also called: OTP input, pin input, verification code input, SMS code input
- Category: Inputs
- Platforms: iOS, Android, web
- Expo Go: yes, no development build needed
- npm dependencies: react-native-svg
- Uses ExpoKit items: kit
- Variants: Verify Phone, Pin, Underline, With Separator, States

## Installation

Run once per project: `npx @expokit/cli@latest init` (shared theme + KitProvider). Then:

```bash
npx @expokit/cli@latest add otp-input
```

The CLI copies the source into your project (you own the code) and installs react-native-svg.

Import: `import { OtpInput } from "@/components/ui/otp-input";`

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `length` | `number` | `6` | Number of cells. |
| `value / onChangeText` | `string` | — | Controlled code (digits only). Pasting a longer string fills every cell. |
| `onComplete` | `(code) => void` | — | Called when every cell is filled. |
| `variant` | `"box" \| "underline" \| "pill"` | `"box"` | Rounded box cells, underline bars, or round pill cells. |
| `error` | `boolean` | `false` | Shakes the row and turns it the danger colour. |
| `errorText` | `string` | — | Message (with icon) shown under the cells while `error` is set. |
| `success` | `boolean` | `false` | Success colour with a staggered pulse across the cells. |
| `successText` | `string` | — | Message with an animated check shown while `success` is set. |
| `helperText` | `string` | — | Hint shown under the cells otherwise. |
| `separatorAfter` | `number` | — | Draw a dash after this many cells, e.g. 3 → 123 – 456. |
| `maxCellSize` | `number` | `52` | Largest cell width; cells shrink to fit the row and never overflow. |
| `secure` | `boolean` | `false` | Dots instead of digits. |
| `disabled` | `boolean` | `false` | Dims and blocks input. |
| `autoFocus` | `boolean` | `false` | Focus on mount. |
| `accent` | `string` | `theme accent` | Active cell colour. |
| `style` | `StyleProp<ViewStyle>` | — | Style for the root view around the cells and message. |
| `className` | `string` | — | Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. |

## Behaviour & accessibility

- **Touch**: Tapping the row focuses one hidden number-pad input. Pasting a code like 123-456 strips the non-digits and fills every cell.
- **Motion**: Digits pop in on a bouncy spring and the active cell glows with a halo and a blinking caret. Errors shake the row; success pulses across the cells.
- **Platforms**: Sets textContentType 'oneTimeCode' and autoComplete 'one-time-code', so codes from SMS can autofill.
- **Screen readers**: The cells are hidden; the input is labelled 'One-time code, 6 digits' with a hint. Helper, error and success messages are a polite live region.
- **Web**: The browser focus outline is removed; the border and halo show focus instead.

## FAQ

### How do I make an OTP input in React Native?

Use ExpoKit's OTP Input: run npx @expokit/cli@latest add otp-input in your Expo or React Native project and it copies a ready-made OTP input into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.

### Does OTP Input work in Expo Go?

Yes. OTP Input runs in Expo Go on iOS and Android with no development build — its packages (react-native-svg) are all included in Expo Go.

### How do I add OTP Input to my Expo app?

Run npx @expokit/cli@latest add otp-input in your project. The CLI copies the component's source into your app and installs react-native-svg, so the code is yours to change.

### Is OTP Input free?

Yes. OTP Input is free: its full source is on this page and the CLI installs it without an account.

### Can I change how OTP Input looks?

Yes. It takes its colours, radius and light / dark mode from useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.

## More

- Live preview, variants and code: https://expokit.in/docs/components/otp-input
- Every ExpoKit component, screen, template and chart: https://expokit.in/llms.txt
- Install commands and props for every free component: https://expokit.in/llms-full.txt
- Pricing: https://expokit.in/pricing
