auto-form-builder
Version:
๐งฑ Vue Auto Form Builder with schema-based generation, themes, validation and localization.
121 lines (93 loc) โข 2.65 kB
Markdown
# ๐งฑ vue-auto-form-builder
[](https://www.npmjs.com/package/auto-form-builder)
A smart and fully customizable Vue 3 component to auto-generate forms using a simple JSON schema.
Supports **RTL**, **Dark Mode**, **themes**, **sections**, **validation**, **i18n**, and more โ all out of the box โก๏ธ
## โจ Features
- ๐ Build forms instantly from a schema
- ๐งโ๐จ Fully customizable styling via `themeConfig`
- ๐งฉ Supports all common field types: text, number, password, file, switch, checkbox, radio, textarea, select, etc.
- ๐ฆ Section-based grouping (with `section` titles)
- โ
Built-in validation (required, min, max, pattern)
- ๐ Multi-language support (EN / AR auto-detect)
- ๐ Auto dark mode support via `prefers-color-scheme`
- ๐ Optional `submitUrl` to POST form data automatically
- ๐งช Works perfectly with Tailwind / Bootstrap
- ๐ก JSON output ready-to-use
- ๐ชถ Lightweight and dependency-free
## ๐ฆ Installation
```bash
npm install auto-form-builder
```
## ๐ Usage
```ts
import { AutoForm } from "auto-form-builder";
```
```vue
<AutoForm :schema="formSchema" @submit="handleSubmit" />
```
## ๐ Schema Example
```ts
const formSchema = [
{
section: "ู
ุนููู
ุงุช ุฃุณุงุณูุฉ",
fields: [
{ name: "name", label: "ุงูุงุณู
", type: "text", required: true },
{
name: "email",
label: "ุงูุจุฑูุฏ ุงูุฅููุชุฑููู",
type: "email",
required: true,
},
{
name: "gender",
label: "ุงูุฌูุณ",
type: "radio",
options: ["ุฐูุฑ", "ุฃูุซู"],
},
],
},
{
section: "ุชูุงุตูู ุฅุถุงููุฉ",
fields: [
{ name: "dob", label: "ุชุงุฑูุฎ ุงูู
ููุงุฏ", type: "date" },
{ name: "resume", label: "ุงูุณูุฑุฉ ุงูุฐุงุชูุฉ", type: "file" },
],
},
];
```
## ๐จ Theme Configuration (optional)
```ts
<AutoForm
:schema="formSchema"
:theme-config="{
input: 'bg-gray-100 rounded border p-2',
label: 'text-gray-700 font-semibold',
submitButton: 'bg-blue-600 text-white py-2 px-4 rounded'
}"
/>
```
## ๐ Project Structure
```
vue-auto-form-builder/
โโโ src/
โ โโโ components/AutoForm.vue
โ โโโ utils/schemaParser.ts
โโโ package.json
โโโ README.md
โโโ tsconfig.json
```
## ๐ ๏ธ Build & Publish
```bash
npm run build
npm publish
```
## ๐ License
[LICENSE](License)