@vjdv/react-forms
v0.3.5
Published
Another aproach to create forms in React with validations
Downloads
2
Maintainers
Readme
React Forms
Easily create your forms
Features
- Built with React Hooks
- Bootstrap support
- Predesigned controls
- Custom form validations
- Easily incorporate your own controls
Installation
npm install @vjdv/react-forms
By default this package uses Bootstrap classes so you may need to install Bootstrap:
npm install [email protected]
And include the css in your project:
@import "bootstrap/scss/bootstrap.scss";
Usage
import { Form, FormSelect, FormTextInput, FormCol, FormRow, FormValidation, useFormState } from "@vjdv/react-forms";
function AddressForm() {
const formstate = useFormState({ addressLine1: "", addressLine2: "", zipCode: "", state: "" });
function confirm() {
return confirm("Are you sure?");
}
//Print current form values
function save() {
console.log(formstate);
console.log("Saved");
}
return (
<Form state={formstate} onSubmit={guardar} confirm={confirm}>
Address line 1:
<FormTextInput name="addressLine1" />
Address line 2:
<FormTextInput name="addressLine2" />
Zip Code:
<FormTextInput name="zipCode" />
State:
<FormSelect name="state" options={states} />
</Form>
);
}