Form OTP Input

GitHub

One-time password input connected to Form context with server validation errors.

Installation

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

Usage

tsx
import { FormOtpInput } from "@/components/cs/form-otp-input"
tsx
<FormOtpInput name="code" maxLength={6} />

API Reference

FormOtpInput

One-time password input connected to Form context with server validation errors.

Props

NameTypeDefaultDescription
childrenReactNode-Custom slots rendered inside the OTP input group.
containerClassNamestring | undefined-Additional classes applied to the OTP slot container.
defaultValuestring-Initial OTP value used before the field is changed.
inputClassNamestring | undefined-Additional classes applied to the OTP input control.
labelstring | undefined-Field label and fallback placeholder.
name *string-Form field name used for submission and validation errors.
patternstring | undefined-You can also use REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS