A dynamic form builder built with React and TypeScript that allows users to create and manage custom form fields in real-time using a centralized state store.
๐ Features
- โ Add fields dynamically (text, number, textarea, date, etc.)
- ๐๏ธ Remove or update individual fields
- ๐ Reset form with one click
- ๐ง Centralized state management using
useFormStore
(e.g., Zustand)
- ๐ฆ Component-based architecture
- ๐จ Styled with Tailwind CSS
- ๐ Type-safe using TypeScript
๐ Tech Stack
- React (with Hooks)
- TypeScript
- Zustand or any state management via
useFormStore
- Tailwind CSS
๐ฆ Installation
git clone https://github.com/Kelsen23/react-form-builder.git
cd react-form-builder
npm install
npm run dev
๐งช How It Works
๐งฉ Adding a Field
The FormBuilder
component manages a local newField
state. Here's the process:
- User types a label (e.g., "Email").
- Selects a field type (e.g.,
text
, number
, date
, etc.).
- Clicks the Add Field button.
- The field is added to the global store using
addField()
from useFormStore
.
๐ Managing Fields
Each form field is rendered using the FormField
component, which allows:
- ๐ Inline editing: Users can modify the label, value, or type.
- โป๏ธ Updating: Changes trigger
updateField(index, updatedField)
.
- โ Removing: Clicking remove calls
removeField(index)
.
- Clicking the Reset Form button calls
resetForm()
from the store.
- This clears all fields and resets the builder to its initial state.
๐ค Contributing
PRs and suggestions are welcome!
Open an issue or fork the project to get started.
๐ License
MIT