SelectField
SelectField normalizes options arrays into { key, value } pairs, supports single and multiple selection modes, clearable options, and an embedded '+ Create New' action button.
Props & Configuration
8 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. |
| optionsRequired | FieldOption[] | — | Array of { key: string, value: string } options. |
| mode | "multiple" | "tags" | — | Enables multi-tag selection mode. |
| showSearch | boolean | true | Enables text filtering across options. |
| allowClear | boolean | true | Shows a cross icon to clear selection. |
| create | SelectCreateAction | — | Config for '+ Add New' button inside dropdown footer. |
| hideKeys | (string | number)[] | — | List of keys to omit from the dropdown list. |
Interactive Examples & Live Previews
2 DemosEvery example includes its own live, interactive preview element alongside the corresponding copyable TypeScript snippet.
Basic Dropdown Selector
Standard single-select dropdown with key-value pairs.
1import React from "react";2import { useForm } from "react-hook-form";3import { SelectField } from "antd-dynamic-ui";45export default function BasicSelect() {6 const { control } = useForm();7 const roles = [8 { key: "admin", value: "Administrator" },9 { key: "editor", value: "Editor" },10 { key: "viewer", value: "Viewer" },11 ];1213 return (14 <div className="max-w-md">15 <SelectField16 id="role"17 control={control}18 label="User Role"19 placeholder="Select access tier"20 options={roles}21 />22 </div>23 );24}
Multi-Select Mode with In-Menu '+ Add Option' Action
Multi-tag selection with search filter and an embedded create new option button.
1import React, { useState } from "react";2import { useForm } from "react-hook-form";3import { SelectField } from "antd-dynamic-ui";4import { PlusOutlined } from "@ant-design/icons";56export default function MultiSelectWithCreate() {7 const { control } = useForm({ defaultValues: { tags: ["react", "typescript"] } });8 const [tagOptions, setTagOptions] = useState([9 { key: "react", value: "React 19" },10 { key: "typescript", value: "TypeScript 5.8" },11 { key: "tailwind", value: "Tailwind CSS" },12 ]);1314 return (15 <div className="max-w-md">16 <SelectField17 id="tags"18 control={control}19 label="Project Technologies"20 placeholder="Select or add tags"21 options={tagOptions}22 mode="multiple"23 showSearch={true}24 allowClear={true}25 create={{26 label: "Add New Technology Tag",27 icon: <PlusOutlined />,28 onClick: () => {29 const newTag = prompt("Enter new tag name:");30 if (newTag) {31 setTagOptions((prev) => [...prev, { key: newTag.toLowerCase(), value: newTag }]);32 }33 },34 }}35 />36 </div>37 );38}
Frequently Asked Questions & Quick Solutions
Architectural patterns, React 19 compatibility, and integration tips for SelectField.
How does SelectField integrate with Ant Design 5.x and Next.js 15?▼
SelectField 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 SelectField?▼
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.