OTP Input

GitHub

One-time password input with optional label, validation message, and generated slots.

Installation

bash
pnpm dlx shadcn@latest add @cs/otp-input

Usage

tsx
import { OtpInput } from "@/components/cs/otp-input";
tsx
<OtpInput name="verification-code" label="Verification code" maxLength={6} />

API Reference

OtpInput

One-time password input with an optional label, validation message, and generated input slots.

Props

NameTypeDefaultDescription
childrenReact.ReactNode-Custom slots rendered inside the OTP input group.
containerClassNamestring-Additional classes applied to the OTP slot container.
errorstring | null-Validation error message for the field.
inputClassNamestring-Additional classes applied to the OTP input control.
labelstring-Field label and fallback placeholder.
patternstring-You can also use REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS