# P otp field 3

> OTP field with separator

A shadcn/ui block from the [@coss](https://coss.com/ui) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/coss/p-otp-field-3).

- Page, with a live preview: https://shadcn.exchange/r/coss/p-otp-field-3
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/coss/p-otp-field-3-light-67f9873d65cafbe6.png
- Registry item: https://coss.com/ui/r/p-otp-field-3.json
- Categories: otp field, input
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://coss.com/ui/r/p-otp-field-3.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@coss/otp-field`

## Files

### `registry/default/particles/p-otp-field-3.tsx`

```tsx
import {
  OTPField,
  OTPFieldInput,
  OTPFieldSeparator,
} from "@/registry/default/ui/otp-field";

const OTP_LENGTH = 6;
const GROUP_LENGTH = 3;

const OTP_SLOT_KEYS = Array.from(
  { length: OTP_LENGTH },
  (_, i) => `otp-slot-${i}`,
);

export default function Particle() {
  return (
    <OTPField aria-label="Verification code" length={OTP_LENGTH}>
      {OTP_SLOT_KEYS.slice(0, GROUP_LENGTH).map((slotKey, index) => (
        <OTPFieldInput
          key={slotKey}
          aria-label={
            index === 0 ? undefined : `Character ${index + 1} of ${OTP_LENGTH}`
          }
        />
      ))}
      <OTPFieldSeparator />
      {OTP_SLOT_KEYS.slice(GROUP_LENGTH).map((slotKey, index) => (
        <OTPFieldInput
          key={slotKey}
          aria-label={`Character ${index + GROUP_LENGTH + 1} of ${OTP_LENGTH}`}
        />
      ))}
    </OTPField>
  );
}
```
