OTP Field
A one-time-password field — a row of character slots that owns focus movement, paste, and completion.
Show codeHide code
Installation
import { OTPField } from "@makeplane/propel/components/otp-field";Usage
import { OTPField } from "@makeplane/propel/components/otp-field";
export default function BasicDemo() {
return <OTPField length={6} size="lg" aria-label="Verification code" />;
}Examples
Sizes
size sets the box size of every slot — lg, xl, and 2xl.
Show codeHide code
Grouped
groups splits the run with separators — [3, 3] renders the 123-456 shape. The counts must sum to length.
Show codeHide code
Hint
hint shows helper text below the slots, e.g. a resend countdown. It’s replaced by error when set.
Show codeHide code
Invalid
Passing error shows the message and flips every slot to the danger state.
Show codeHide code
Controlled
normalizeValue rewrites accepted characters while rejected ones surface through onValueInvalid, fed back as an error until the next valid keystroke clears it.
Show codeHide code
API Reference
OTPField
The ready-made one-time-password / verification-code field: a row of length character slots.
Drive it with value/defaultValue + onValueChange; the root owns focus movement, paste, and
completion across the slots. Pass mask to obscure entered characters, size to set the box
size, hint for helper text below the slots (e.g. a resend countdown), and error to show an
error message instead — Field.Root invalid then propagates data-invalid to every slot, which
recolors its border (and focus ring) to danger off that state.
Grafts Base UI OTPField behavior onto the elements/otp-field styled parts (OTPField root +
OTPFieldInput). Each slot resolves its index from the root context, so the ready-made simply
renders one per slot; groups splits the run with separators (e.g. groups={[3, 3]} renders
123-456).