A dynamic form builder application built with React that allows you to create custom forms similar to Google Forms. Users can design forms with various input types and view the form in preview mode before publishing.
- Create custom forms with different input types:
- Text inputs
- Number inputs
- Select/Options inputs
- Configure validation rules for each input:
- Required fields
- Min/max text length
- Min/max number values
- Live preview of your form
- Auto-save draft entries while editing
- Form validation on submission
- Responsive UI with Tailwind CSS
Check out the live demo: React Form Builder Demo
- Node.js (version 14.x or higher recommended)
- npm or yarn
- Clone the repository
git clone https://github.com/shirshendubhowmick/form-builder.git
- Navigate to the project directory
cd form-builder
- Install dependencies
npm install
- Start the development server
npm run dev
- Open your browser and visit:
http://localhost:3000
-
Form Builder Mode:
- Add questions by filling in the form and clicking "Add"
- Configure question properties (required, min/max values, etc.)
- Edit existing questions by expanding them in the accordion
- Remove questions with the trash icon
-
Preview Mode:
- Click "Switch to Preview" to see how your form will look to users
- Test form validation by submitting the form
- Return to builder mode by clicking "Switch to Builder"
- React
- TypeScript
- Tailwind CSS for styling
- Zod for schema validation
- Radix UI for accessible UI components
- React Toastify for notifications
- Vite for fast development and building
While interacting with the app, you may face API errors. These are simulated errors to test the error handling of the app. The errors occur randomly based on a set probability. You can change the probability of errors in the api.ts file by adjusting the value of ERROR_PROBABILITY
.
src/
├── components/ # Reusable UI components
├── schemas/ # Zod validation schemas
├── services/ # API and storage services
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── views/ # Main view components
│ ├── Builder/ # Form builder interface
│ └── Renderer/ # Form preview interface
├── App.tsx # Main application component
└── index.tsx # Entry point
npm run dev
- Start the development servernpm run build
- Build the application for productionnpm run lint-staged
- Run linters on staged files (pre-commit)
This project is licensed under the MIT License.
Shirshendu Bhowmick