---
title: OTP Field
description: An accessible and customizable OTP Input component.

link:
  doc: https://corvu.dev/docs/primitives/otp-field/
  api: https://corvu.dev/docs/primitives/otp-field/#api-reference
---

<ComponentPreview name="otp-field-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/otp-field-demo.tsx

```

</ComponentPreview>

## Installation

<ComponentInstallation>

<Step>

<StepItem>Copy and paste the following code into your project:</StepItem>

  <ComponentSourceTabs>

    ```tsx title="components/ui/otp-field" file=<rootDir>/apps/docs/src/registry/ui/otp-field.tsx

    ```

    ```tsx title="components/ui/otp-field" file=<rootDir>/apps/unocss-playground/src/registry/ui/otp-field.tsx

    ```

  </ComponentSourceTabs>

</Step>

</ComponentInstallation>

## Usage

```tsx
import {
  OTPField,
  OTPFieldGroup,
  OTPFieldInput,
  OTPFieldSeparator,
  OTPFieldSlot,
} from "@/components/ui/otp-field"
```

```tsx
<OTPField>
  <OTPFieldInput />
  <OTPFieldGroup>
    <OTPFieldSlot index={0} />
    <OTPFieldSlot index={1} />
    <OTPFieldSlot index={2} />
  </OTPFieldGroup>
  <OTPFieldSeparator />
  <OTPFieldGroup>
    <OTPFieldSlot index={3} />
    <OTPFieldSlot index={4} />
    <OTPFieldSlot index={5} />
  </OTPFieldGroup>
</OTPField>
```
