---
title: Input OTP
description: Accessible one-time password component with copy paste functionality.
base: base
component: true
links:
doc: https://input-otp.rodz.dev
---
## About
Input OTP is built on top of [input-otp](https://github.com/guilhermerodz/input-otp) by [@guilherme_rodz](https://twitter.com/guilherme_rodz).
## Installation
Command
Manual
```bash
npx shadcn@latest add input-otp
```
Install the following dependencies:
```bash
npm install input-otp
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Usage
```tsx showLineNumbers
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/components/ui/input-otp"
```
```tsx showLineNumbers
```
## Pattern
Use the `pattern` prop to define a custom pattern for the OTP input.
```tsx showLineNumbers {1,5}
import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp"
;
...
```
## Examples
### Separator
Use the `` component to add a separator between input groups.
### Disabled
Use the `disabled` prop to disable the input.
### Controlled
Use the `value` and `onChange` props to control the input value.
### Invalid
Use `aria-invalid` on the slots to show an error state.
### Four Digits
A common pattern for PIN codes. This uses the `pattern={REGEXP_ONLY_DIGITS}` prop.
### Alphanumeric
Use `REGEXP_ONLY_DIGITS_AND_CHARS` to accept both letters and numbers.
### Form
## RTL
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
## API Reference
See the [input-otp](https://input-otp.rodz.dev) documentation for more information.