OtpField
OtpField provides segmented digit boxes for SMS verification codes and authenticator tokens.
Props & Configuration
4 propsComplete property specifications, parameter types, and default fallbacks.
| Property | Type | Default | Description |
|---|---|---|---|
| idRequired | string | — | Form state key name. |
| controlRequired | Control<any> | — | React Hook Form control instance. |
| length | number | 6 | Number of OTP digit boxes. |
| size | "small" | "middle" | "large" | "large" | Input size. |
Interactive Examples & Live Previews
1 DemosEvery example includes its own live, interactive preview element alongside the corresponding copyable TypeScript snippet.
6-Digit SMS Verification Code
Segmented 6-digit OTP code input.
1import React from "react";2import { useForm } from "react-hook-form";3import { OtpField } from "antd-dynamic-ui";45export default function TwoFactorOtp() {6 const { control } = useForm();7 return (8 <div className="max-w-sm">9 <label className="text-sm font-semibold mb-2 block">Enter 6-digit code</label>10 <OtpField id="twoFactorCode" control={control} length={6} size="large" />11 </div>12 );13}
Frequently Asked Questions & Quick Solutions
Architectural patterns, React 19 compatibility, and integration tips for OtpField.
How does OtpField integrate with Ant Design 5.x and Next.js 15?▼
OtpField is designed as an enhanced, declarative wrapper for Ant Design. It fully supports Next.js 15 App Router when using @ant-design/nextjs-registry, eliminating SSR hydration mismatches and guaranteeing 0ms layout thrashing.
Can I customize validation, themes, and props for OtpField?▼
Yes. Every prop is fully typed in TypeScript 5 with comprehensive Intellisense. You can pass custom styling via className or style props, configure global Ant Design themes via ConfigProvider, and extend validation logic seamlessly.