The PnP DynamicForm control for SPFx lets you render list forms dynamically within your web parts, without duplicating setup logic or UI code.
π Key Benefits
- Renders SharePoint list forms based on schema and list settings
- Minimal code required β just configure context, list ID, and callbacks
- Hooks like
onBeforeSubmit,onSubmitted, andonSubmitErrorlet you control custom logic
β Usage Example
Import the control:
import { DynamicForm } from "@pnp/spfx-controls-react/lib/DynamicForm";
Add it inside your component:
<DynamicForm
context={this.props.context}
listId="3071c058-549f-461d-9d73-8b9a52049a80"
listItemId={14}
onBeforeSubmit={(data) => {
console.log("Before submit:", data);
return data;
}}
onSubmitted={(data) => {
console.log("Submitted:", data);
}}
/>
This control pulls the list fields, builds the form, applies validation, and handles submission.
π₯ Demo Walkthrough
Check out the step-by-step video demo showing how to set up and use this control:
π GitHub Sample Project
View full SPFx project on GitHub:SPFx PnP DynamicForm Sample
π§ Notes from the Author
I developed this control as part of the PnP SPFx Controls initiative to simplify form handling in SPFx. The goal was to help developers build dynamic, data-driven SharePoint forms without manually writing repetitive UI code for each list.
- Re-rendering with new
listItemId: If you switch items dynamically, unmount/remount theDynamicForm(e.g., change akey) so the control re-initializes with the new item. - Selective visibility: Use
hiddenFieldsto hide columns you donβt want to expose in the UI.
β Final Thoughts
The PnP DynamicForm control standardizes form UI in SPFx, saves you from boilerplate, and gives you hooks to plug in business logic.
Give it a try β comment with feedback or custom use cases!


