OTP Input
otp-inputA one-time code field drawn as a box per character over one real input, so typing, paste, SMS autofill, Android keyboards and screen readers all just work. Overwrites in place, shakes on a wrong code, draws a check on a right one.
"use client";
import { useState } from "react";
import { OtpInput } from "@/components/forme/otp-input/otp-input";
export function OtpInputDemo() {
const [status, setStatus] = useState<"idle" | "checking" | "ok" | "wrong">("idle");
return (
<div className="flex flex-col gap-8">
<OtpInput
label="Verification code"
groupSize={3}
description={status === "checking" ? "Checking…" : "Paste or type the code we sent you."}
error={status === "wrong" ? "That code did not match. Try 424242." : undefined}
success={status === "ok" ? "Verified." : undefined}
onChange={() => setStatus("idle")}
onComplete={(code) => {
setStatus("checking");
setTimeout(() => setStatus(code === "424242" ? "ok" : "wrong"), 600);
}}
/>
<OtpInput label="Card PIN" length={4} mask description="Four digits, hidden as you type." />
<OtpInput
label="Recovery key"
length={6}
mode="alphanumeric"
groupSize={3}
defaultValue="A7K"
/>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
OtpInput
A one-time code field, drawn as one box per character.
| Prop | Type | Default | Description |
|---|---|---|---|
label* | string | — | Visible label. |
length | number | 6 | Number of characters. Six is the common case. |
value | string | — | |
defaultValue | string | "" | |
onChange | (value: string) => void | — | |
onComplete | (value: string) => void | — | Called whenever the code becomes complete, including after a correction. Submit from here. |
mode | "numeric" | "alphanumeric" | "numeric" | Digits only by default. Pass "alphanumeric" for codes like A7K2QX. |
groupSize | number | — | Draws a separator after this many characters, e.g. 3 for 123 456. |
description | string | — | Help text under the field. Replaced by error or a success message. |
error | string | — | Marks the code wrong: the boxes shake once and the message is announced. |
success | boolean | string | — | Marks the code accepted and draws a check. A string is shown as the message. |
mask | boolean | false | Shows dots instead of the characters. |
disabled | boolean | — | |
autoFocus | boolean | — | |
name | string | — | |
className | string | — |
Related


Calendar
A month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, min, max and disabled days, a range that previews under the pointer, and a fixed six-week height so nothing below it jumps.
inputs

File Dropzone
A drop target that is also a real file picker, so click, keyboard and drag all work. Checks type and size on drop as well as in the picker, and reports each rejected file by name.
inputs

Input
A text field with a real label, optional description, an error that is announced and wired up with aria-describedby, and room for an icon on either side. Sizes and the invalid state come from the same tokens as every other Forme surface.
inputs