OTP Input
OTP Input captures a fixed-length value and exposes completion and status callbacks.
Practical React example
Collect a one-time passcode and display the verification result returned by your authentication service.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/motion/otp-input.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, motion, react, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Collect a one-time passcode and display the verification result returned by your authentication service
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { useState } from "react";
import { OTPInput, type OTPStatus } from "@/components/motion/otp-input";
const CODE = "123456";
export function OTPInputPreview() {
const [value, setValue] = useState("");
const [status, setStatus] = useState<OTPStatus>("idle");
return (
<div className="flex flex-col items-center gap-4">
<OTPInput
label="Verification code"
hint={`Enter ${CODE} to verify.`}
successMessage="Verified."
errorMessage="Wrong code, try again."
value={value}
status={status}
onChange={(v) => {
setValue(v);
if (status !== "idle") setStatus("idle");
}}
onComplete={(v) => setStatus(v === CODE ? "success" : "error")}
/>
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Send the completed value through your existing verification flow. Set success only after the server confirms the challenge, and model expiry and resend separately.
Customization
- OTPInputProps.length
- Optional; number. Number of slots. Default 6.
- OTPInputProps.value
- Optional; string.
- OTPInputProps.defaultValue
- Optional; string.
- OTPInputProps.onChange
- Optional; (value: string) => void.
- OTPInputProps.onComplete
- Optional; (value: string) => void. Fires once every slot is filled.
- OTPInputProps.label
- Optional; string. Optional label rendered above the slots.
- OTPInputProps.hint
- Optional; string. Helper text shown below the slots while idle.
- OTPInputProps.successMessage
- Optional; string. Message shown below the slots when status is "success".
- OTPInputProps.errorMessage
- Optional; string. Message shown below the slots when status is "error".
- OTPInputProps.status
- Optional; OTPStatus. External validation feedback. "error" shakes, "success" draws a check.
- OTPInputProps.mask
- Optional; boolean. Render dots instead of the typed digits.
- OTPInputProps.disabled
- Optional; boolean.
- OTPInputProps.autoFocus
- Optional; boolean.
- OTPInputProps."aria-label"
- Optional; string. Accessible label for the underlying input.
Integration notes
- Length and visual success do not validate a code; enforce expiry, attempt limits and challenge binding server-side.
- Do not log codes or include them in analytics events.
Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.