# V otp field 10

> Email verification card

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/v-otp-field-10).

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

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-otp-field-10.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: `@cnippet/otp-field`

## Files

### `registry/default/variants/v-otp-field-10.tsx`

```tsx
"use client";

import { useState } from "react";
import { Button } from "@/registry/default/ui/button";
import { Field, FieldLabel } from "@/registry/default/ui/field";
import { OTPField, OTPFieldInput } from "@/registry/default/ui/otp-field";

const PIN_LENGTH = 4;
const CORRECT_PIN = "1234";

const PIN_SLOT_KEYS = Array.from(
  { length: PIN_LENGTH },
  (_, i) => `pin-slot-${i}`,
);

export default function Particle() {
  const [value, setValue] = useState("");
  const [status, setStatus] = useState<"idle" | "error" | "success">("idle");

  function handleVerify() {
    if (value === CORRECT_PIN) {
      setStatus("success");
    } else {
      setStatus("error");
      setValue("");
    }
  }

  if (status === "success") {
    return (
      <div className="flex flex-col items-center gap-2 text-center">
        <span className="text-2xl">✓</span>
        <p className="font-medium text-sm">PIN accepted</p>
        <Button onClick={() => setStatus("idle")} size="sm" variant="outline">
          Reset
        </Button>
      </div>
    );
  }

  return (
    <div className="flex flex-col items-center gap-4">
      <Field className="items-center gap-3">
        <FieldLabel>Enter your PIN</FieldLabel>
        <OTPField
          aria-label="4-digit PIN"
          inputMode="numeric"
          length={PIN_LENGTH}
          mask
          onValueChange={(v) => {
            setStatus("idle");
            setValue(v);
          }}
          value={value}
        >
          {PIN_SLOT_KEYS.map((key, index) => (
            <OTPFieldInput
              aria-label={`PIN digit ${index + 1} of ${PIN_LENGTH}`}
              key={key}
            />
          ))}
        </OTPField>
        {status === "error" && (
          <p className="text-destructive text-xs">Incorrect PIN. Try again.</p>
        )}
      </Field>
      <Button
        disabled={value.length < PIN_LENGTH}
        onClick={handleVerify}
        size="sm"
      >
        Confirm
      </Button>
    </div>
  );
}
```
