DynamicModal
DynamicModal wraps ReactModal with Ant Design theme tokens, smooth enter/leave fade animations, overlay dismiss controls, header action slots, and accessible ARIA attributes. Designed to host complex forms, audit logs, and detail views without clipping or z-index collisions.
Props & Configuration
10 propsComplete property specifications, parameter types, and default fallbacks.
| Property | Type | Default | Description |
|---|---|---|---|
| isOpenRequired | boolean | — | Controls modal visibility state. |
| onCloseRequired | () => void | — | Callback triggered when clicking overlay, close icon, or pressing Escape key. |
| title | React.ReactNode | — | Header title text or custom JSX node. |
| headerAction | React.ReactNode | — | Optional JSX rendered on the right side of the header next to the close icon. |
| footer | React.ReactNode | — | Modal footer content (e.g. Cancel and Save buttons). |
| close | "icon" | "text" | "icon" | Close button appearance: SVG cross icon or text link. |
| hideCloseButton | boolean | false | Hides the header close button entirely. |
| bodyClassName | string | — | Custom CSS class applied to the scrollable modal body area. |
| headerClassName | string | — | Custom CSS class applied to the modal header container. |
| zIndex | number | 50 | Custom stacking z-index for nested overlays. |
Interactive Examples & Live Previews
3 DemosEvery example includes its own live, interactive preview element alongside the corresponding copyable TypeScript snippet.
Basic Controlled Modal
Standard modal dialog with title and default close icon.
1import React, { useState } from "react";2import { DynamicModal, ButtonField } from "antd-dynamic-ui";34export default function BasicModalExample() {5 const [isOpen, setIsOpen] = useState(false);67 return (8 <div className="p-4">9 <ButtonField type="primary" onClick={() => setIsOpen(true)}>10 Open Confirmation Modal11 </ButtonField>1213 <DynamicModal14 isOpen={isOpen}15 onClose={() => setIsOpen(false)}16 title="Notice"17 >18 <div className="py-4 text-sm text-[#5c4738]">19 This action will export user profiles to the designated cold storage bucket.20 </div>21 </DynamicModal>22 </div>23 );24}
Complete Props with Header Action & Sticky Footer
Advanced modal with header action link, sticky footer buttons, body styling, and custom z-index.
1import React, { useState } from "react";2import { DynamicModal, ButtonField } from "antd-dynamic-ui";3import { Tag } from "antd";4import { ExternalLink } from "lucide-react";56export default function CompleteModalExample() {7 const [isOpen, setIsOpen] = useState(false);8 const [isSaving, setIsSaving] = useState(false);910 const handleSave = async () => {11 setIsSaving(true);12 await new Promise((r) => setTimeout(r, 1000));13 setIsSaving(false);14 setIsOpen(false);15 };1617 return (18 <div className="p-4">19 <ButtonField type="primary" onClick={() => setIsOpen(true)}>20 Inspect Security Permissions21 </ButtonField>2223 <DynamicModal24 isOpen={isOpen}25 onClose={() => setIsOpen(false)}26 title={27 <div className="flex items-center gap-2">28 <span>Security Policy #SEC-9021</span>29 <Tag color="gold">Audited</Tag>30 </div>31 }32 headerAction={33 <a34 href="https://docs.enterprise.io/security"35 target="_blank"36 rel="noreferrer"37 className="flex items-center gap-1 text-xs text-blue-600 hover:underline"38 >39 <span>Policy Specs</span>40 <ExternalLink size={12} />41 </a>42 }43 footer={44 <div className="flex justify-end gap-2 w-full">45 <ButtonField type="default" onClick={() => setIsOpen(false)}>46 Cancel47 </ButtonField>48 <ButtonField type="primary" loading={isSaving} onClick={handleSave}>49 Apply Security Rules50 </ButtonField>51 </div>52 }53 close="icon"54 zIndex={100}55 bodyClassName="max-h-[60vh] overflow-y-auto space-y-3 p-6"56 >57 <p className="text-sm text-[#5c4738]">58 Enforce multi-factor authentication (MFA) and biometric passkeys for all59 administrative accounts in the engineering organization.60 </p>61 </DynamicModal>62 </div>63 );64}
Modal Hosting an Embedded DynamicForm
DynamicModal embedding a dynamic form that automatically validates and closes upon submission.
1import React, { useState } from "react";2import { DynamicModal, DynamicForm, FormSchema, ButtonField } from "antd-dynamic-ui";3import { message } from "antd";45const editUserSchema: FormSchema = {6 rows: [7 [8 { id: "displayName", type: "text", label: "Display Name", required: true, span: 12 },9 { id: "department", type: "select", label: "Department", options: [{ key: "eng", value: "Engineering" }, { key: "sales", value: "Sales" }], span: 12 },10 ]11 ]12};1314export default function ModalWithDynamicForm() {15 const [isOpen, setIsOpen] = useState(false);1617 return (18 <div className="p-4">19 <ButtonField type="primary" onClick={() => setIsOpen(true)}>20 Edit User Profile21 </ButtonField>2223 <DynamicModal24 isOpen={isOpen}25 onClose={() => setIsOpen(false)}26 title="Edit User Profile"27 >28 <DynamicForm29 schema={editUserSchema}30 initialValues={{ displayName: "Grace Hopper", department: "eng" }}31 onSubmit={async (data) => {32 message.success("Profile updated successfully!");33 console.log("Updated data:", data);34 setIsOpen(false);35 }}36 submitText="Update Profile"37 />38 </DynamicModal>39 </div>40 );41}
Frequently Asked Questions & Quick Solutions
Architectural patterns, React 19 compatibility, and integration tips for DynamicModal.
How does DynamicModal integrate with Ant Design 5.x and Next.js 15?▼
DynamicModal 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 DynamicModal?▼
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.