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, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
inputsColor picker
A full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
inputsColor selector
A row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
inputs