mini-form-builder
v0.0.2
Published
A lightweight dynamic React form builder library with TypeScript support.
Readme
Mini Form Builder
A lightweight dynamic React form builder library with TypeScript support.
Features
- Dynamic form generation
- TypeScript support
- Custom field rendering
- Validation support
- Responsive layout
- Easy integration
- React 18 / 19 support
Installation
npm install mini-form-builderOR
yarn add mini-form-builderUsage
import { MiniFormBuilder } from "mini-form-builder";
const schema = {
fields: [
{
name: "name",
label: "Name",
type: "text",
placeholder: "Enter name",
},
{
name: "email",
label: "Email",
type: "email",
placeholder: "Enter email",
},
],
};
export default function App() {
return (
<MiniFormBuilder
schema={schema}
onSubmit={(values) => {
console.log(values);
}}
/>
);
}Schema Example
const schema = {
fields: [
{
name: "username",
label: "Username",
type: "text",
placeholder: "Enter username",
validation: {
required: true,
},
},
{
name: "password",
label: "Password",
type: "password",
validation: {
required: true,
minLength: 6,
},
},
{
name: "gender",
label: "Gender",
type: "select",
options: [
{
label: "Male",
value: "male",
},
{
label: "Female",
value: "female",
},
],
},
],
};Props
| Prop | Type | Description |
|---|---|---|
| schema | FormSchema | Form configuration |
| onSubmit | (values) => void | Submit callback |
| className | string | Custom wrapper class |
Field Types
Supported field types:
- text
- password
- number
- textarea
- select
- checkbox
- radio
- date
TypeScript
import type {
FormSchema,
Field,
} from "mini-form-builder";Example Validation
validation: {
required: true,
minLength: 3,
maxLength: 20,
}Styling
You can fully customize styles using:
className
style
field.styleReact Version Support
- React 18
- React 19
License
MIT
