InputField
InputField connects Ant Design's Input to React Hook Form. It supports inline prefixes (icons), addonBefore/addonAfter (protocols, domain suffixes), max character limits, info tooltips, and custom change listeners.
Props & Configuration
16 propsComplete property specifications, parameter types, and default fallbacks.
| Property | Type | Default | Description |
|---|---|---|---|
| idRequired | string | — | Form state key name registered in React Hook Form. |
| control | Control<any> | — | React Hook Form control instance (optional if inside FormProvider). |
| label | string | — | Field label displayed above the input. |
| placeholder | string | — | Watermark placeholder text. |
| tooltip | string | — | Informational tooltip text shown next to the label. |
| helpText | string | — | Subordinate hint or disclaimer rendered below the input. |
| required | boolean | false | Renders a red asterisk next to the label. |
| disabled | boolean | false | Disables user interaction. |
| prefix | React.ReactNode | — | Icon or element placed inside the left edge of the input. |
| suffix | React.ReactNode | — | Icon or element placed inside the right edge of the input. |
| addonBefore | React.ReactNode | — | Addon box attached before the input. |
| addonAfter | React.ReactNode | — | Addon box attached after the input. |
| maxLength | number | — | Maximum character length permitted. |
| onChange | (val: any) => void | — | Custom change listener triggered on every keystroke. |
| rules | RegisterOptions | — | React Hook Form validation rules (pattern, minLength, required). |
| span | number | 24 | Grid column span out of 24 when rendered inside DynamicForm rows. |
Interactive Examples & Live Previews
3 DemosEvery example includes its own live, interactive preview element alongside the corresponding copyable TypeScript snippet.
Basic React Hook Form Input
Standard controlled single-line text input with label and placeholder.
1import React from "react";2import { useForm } from "react-hook-form";3import { InputField } from "antd-dynamic-ui";45export default function BasicInputExample() {6 const { control, handleSubmit } = useForm({7 defaultValues: { fullName: "Ada Lovelace" },8 });910 return (11 <form onSubmit={handleSubmit((d) => console.log(d))} className="max-w-md space-y-4">12 <InputField13 id="fullName"14 control={control}15 label="Full Name"16 placeholder="e.g. John Doe"17 required={true}18 />19 </form>20 );21}
Complete Props with URL Addons & Prefix Icons
Demonstrating addonBefore, addonAfter, prefix icon, tooltip, and live change listener.
1import React from "react";2import { useForm } from "react-hook-form";3import { InputField } from "antd-dynamic-ui";4import { LinkOutlined } from "@ant-design/icons";56export default function CompleteInputExample() {7 const { control } = useForm({8 defaultValues: { customDomain: "acme-corp" },9 });1011 return (12 <div className="max-w-md space-y-4">13 <InputField14 id="customDomain"15 control={control}16 label="Custom Subdomain"17 tooltip="Your public vanity URL endpoint"18 helpText="Only lowercase letters and hyphens allowed"19 addonBefore="https://"20 addonAfter=".saas-hub.io"21 prefix={<LinkOutlined className="text-zinc-400" />}22 maxLength={30}23 required={true}24 onChange={(val) => console.log("Current value:", val)}25 />26 </div>27 );28}
Declarative DynamicForm Schema Row
How to define InputField in backend JSON schemas for DynamicForm.
1import { FieldConfig } from "antd-dynamic-ui";23// JSON object sent by backend API4export const inputFieldSchema: FieldConfig = {5 id: "corporateEmail",6 type: "text",7 label: "Corporate Email Address",8 placeholder: "alex@company.com",9 tooltip: "Must match your corporate SSO domain",10 helpText: "We will send an activation link to this address",11 required: true,12 span: 12,13 validation: {14 required: true,15 pattern: "^[a-zA-Z0-9._%+-]+@company\\.com$",16 customMessage: "Must be a valid @company.com email address",17 },18};
Frequently Asked Questions & Quick Solutions
Architectural patterns, React 19 compatibility, and integration tips for InputField.
How does InputField integrate with Ant Design 5.x and Next.js 15?▼
InputField 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 InputField?▼
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.