Skip to content

luthfidi/react-form-handling-chakraui

Repository files navigation

React Form Mastery

A comprehensive guide to building complex forms with React Hook Form and Zod schema validation. This project demonstrates various form patterns and validation techniques with a clean, professional UI built using Chakra UI.

Features

  • TypeScript for type safety and better developer experience
  • React Hook Form for efficient form state management
  • Zod for powerful schema validation
  • Chakra UI for beautiful and accessible UI components

Complete Form Examples

  1. Basic Registration Form - Learn fundamental form validation including required fields, email format, and password matching.

  2. Multi-step Form - Create wizard-style forms with state persistence between steps using Zustand.

  3. Dependent Fields Form - Build forms with conditional fields that appear or change based on values entered in other fields.

  4. Array Fields Form - Handle dynamic arrays of fields with add/remove functionality - perfect for managing lists of items.

  5. File Upload Form - Implement file uploads with comprehensive validation for file type, size, and count limitations.

  6. Nested Objects Form - Structure complex forms with deeply nested objects while maintaining clean validation and error handling.

  7. Async Validation Form - Implement server-side validation checks such as username availability.

  8. Custom Validation Form - Create sophisticated custom validation logic beyond what schema validation provides out of the box.

  9. Dynamic Fields Form - Generate form fields dynamically based on external data or API responses.

  10. Internationalized Forms - Build forms with multi-language support for labels, placeholders, and error messages.

Getting Started

Prerequisites

  • Node.js 14.x or later
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/yourusername/react-form-handling.git
cd react-form-handling

# Install dependencies
npm install

# Start the development server
npm run dev

Visit http://localhost:5173 to view the application.

Tech Stack

  • React 18+
  • TypeScript
  • Vite
  • React Hook Form
  • Zod
  • Chakra UI
  • React Router
  • Zustand (for state management)

Acknowledgements

This project was created for educational purposes to demonstrate advanced form handling techniques in React applications.

Languages