Giter Site home page Giter Site logo

eliteknightdeveloper / react-hook-form-headlessui Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 91 KB

This is the sample project using React-Hook-Form with HeadlessUI

Home Page: https://react-hook-form-headlessui.vercel.app

License: MIT License

TypeScript 94.71% JavaScript 2.19% CSS 3.10%

react-hook-form-headlessui's Introduction

About

This repo demonstartes how to use Headless UI components with the React Hook Form by creating wrapper over for headless ui components for better resuability and then hooking up them with the react hook form library and start using them in forms without breaking a sweat.

Components covered -

Refer the following blogpost for more details

Good to know

The headless ui components like combobox and radio group use an array of options and each option in this array is an object. By default, headless ui sends you the complete information of selected option i.e the complete object of the selected option. But, it is very rare that you'll need this. So, I have modified the components to return only the value of the selected option instead of complete object. If you want to stick to the default behaviou you can use the default components i.e, ComboBoxDefault and RadioGroupDefault.

The Combobox also has an ongoing bug/enhancement where the options are not displayed automatically on field focus. This has also been taken care of with the help of this thread

I also noticed a class "select-none" added to <Combobox.Option /> which caused issues for me like moving the cursor to the extreme left (starting of input field) on selection of an option from the mouse. Hence, I have removed it. Because, anyways the design of these components is upto the users.

Demo

A working demo for the same can be found at https://rhf-with-headlessui.vercel.app

This project is deployed using the Vercel Platform from the creators of Next.js.

Getting Started on local

This is a Next.js project bootstrapped with create-next-app.

To run this project locally make sure that you have Node.js 14.6.0 or newer

Next, Clone this repo and run the following commands

npm install
#followed by
npm run dev # or
yarn dev
# or
pnpm dev

Open http://localhost:3000 or the URL displayed on terminal with your browser to see the result.

react-hook-form-headlessui's People

Contributors

eliteknightdeveloper avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.