A powerful, flexible, and customizable form builder component library for Vue 3 applications. Build dynamic forms with drag-and-drop functionality, multiple field types, internationalization support, and seamless integration with your existing Vue ecosystem.
- π Vue 3 + TypeScript - Built with modern Vue 3 Composition API and full TypeScript support
- π― Drag & Drop - Intuitive drag-and-drop interface for building forms
- π Multiple Field Types - Text, Number, Textarea, Select, Checkbox, Radio, Date, File, Button, Heading, Paragraph, Hidden
- π Internationalization - Multi-language support (English, French, Spanish, Arabic, Russian, Chinese)
- π¨ Customizable Styling - Built with Tailwind CSS and Naive UI components
- π± Responsive Design - Works seamlessly on desktop and mobile devices
- πΎ Export/Import - Save and load form configurations as JSON
- π§© Component-based - Easy to integrate with existing Vue applications
- π§ Highly Configurable - Extensive customization options
- π Form Rendering - Built-in form renderer component
npm install form-builder
yarn add form-builder
pnpm add form-builder
<template>
<FormBuilder @save="handleSave" />
</template>
<script setup lang="ts">
import { FormBuilder } from 'form-builder'
const handleSave = sections => {
console.log('Form saved:', sections)
}
</script>
<template>
<FormBuilder :options="formBuilderOptions" :sections="initialSections" @save="handleSave" />
</template>
<script setup lang="ts">
import { FormBuilder } from 'form-builder'
const formBuilderOptions = {
language: 'en',
allowExport: true,
allowImport: true,
}
const initialSections = [
{
id: 'section-1',
title: 'Personal Information',
fields: [
{
id: 'name',
type: 'text',
label: 'Full Name',
required: true,
placeholder: 'Enter your full name',
},
],
},
]
const handleSave = sections => {
console.log('Form saved:', sections)
}
</script>
<template>
<div>
<h2>Form Preview</h2>
<FormRenderer :sections="formSections" @update="handleFormUpdate" />
</div>
</template>
<script setup lang="ts">
import { FormRenderer } from 'form-builder'
const handleFormUpdate = formData => {
console.log('Form data updated:', formData)
}
</script>
Prop | Type | Default | Description |
---|---|---|---|
options |
FormBuilderOptions |
{} |
Configuration options for the form builder |
sections |
FormSection[] |
[] |
Initial form sections |
Event | Payload | Description |
---|---|---|
save |
FormSection[] |
Emitted when form is saved |
interface FormBuilderOptions {
language?: 'en' | 'fr' | 'es' | 'ar' | 'ru' | 'zh'
allowExport?: boolean
allowImport?: boolean
}
Prop | Type | Default | Description |
---|---|---|---|
sections |
FormSection[] |
[] |
Form sections to render |
Event | Payload | Description |
---|---|---|
update |
Record<string, any> |
Emitted when form data changes |
interface FormSection {
id: string
title?: string
fields: FormField[]
editable?: boolean
}
interface FormField {
id: string
type: string
subType?: string
name: string
label: string
required?: boolean
value?: any
editable?: boolean
category?: FieldCategory
class?: string
placeholder?: string
helpText?: string
min?: number
max?: number
step?: number
options?: SelectOption[]
multiple?: boolean
}
Field Type | Description | Icon |
---|---|---|
text |
Single-line text input | π |
number |
Numeric input | π’ |
textarea |
Multi-line text input | π |
select |
Dropdown selection | π |
checkbox |
Checkbox input | βοΈ |
radio |
Radio button group | π |
date |
Date picker | π |
file |
File upload | π |
button |
Action button | π |
heading |
Section heading | π° |
paragraph |
Text paragraph | π |
hidden |
Hidden input field | ποΈβπ¨οΈ |
The library supports multiple languages out of the box:
- πΊπΈ English (en)
- π«π· French (fr)
- πͺπΈ Spanish (es)
- πΈπ¦ Arabic (ar)
- π·πΊ Russian (ru)
- π¨π³ Chinese (zh)
import { FormBuilder } from 'form-builder'
// Add custom language
const customMessages = {
field: {
text: 'Champ de texte',
button: 'Bouton',
// ... other translations
}
}
// Use in component
<FormBuilder :options="{ language: 'custom' }" />
The library uses Tailwind CSS for styling and Naive UI for components. You can customize the appearance by:
/* Override default styles */
.form-builder {
/* Your custom styles */
}
.form-builder .field-item {
/* Custom field styling */
}
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
'form-builder-primary': '#your-color',
},
},
},
}
<template>
<div class="container mx-auto p-4">
<FormBuilder
:options="{
language: 'en',
allowExport: true,
allowImport: true,
}"
@save="handleSave"
/>
</div>
</template>
<script setup lang="ts">
import { FormBuilder } from 'form-builder'
const handleSave = sections => {
// Handle form save
console.log('Saved sections:', sections)
}
</script>
<template>
<div class="container mx-auto p-4">
<FormBuilder :options="builderOptions" :sections="initialSections" @save="handleSave" />
<div class="mt-8">
<h3 class="text-lg font-semibold mb-4">Form Preview</h3>
<FormRenderer :sections="formSections" @update="handleFormUpdate" />
</div>
</div>
</template>
<script setup lang="ts">
import { FormBuilder, FormRenderer } from 'form-builder'
import { ref } from 'vue'
const formSections = ref([])
const builderOptions = {
language: 'en',
allowExport: true,
allowImport: true,
}
const initialSections = [
{
id: 'contact-info',
title: 'Contact Information',
fields: [
{
id: 'email',
type: 'text',
label: 'Email Address',
required: true,
placeholder: 'Enter your email',
},
{
id: 'phone',
type: 'text',
label: 'Phone Number',
placeholder: 'Enter your phone number',
},
],
},
]
const handleSave = sections => {
formSections.value = sections
console.log('Form saved:', sections)
}
const handleFormUpdate = formData => {
console.log('Form data:', formData)
}
</script>
- Node.js 16+
- Vue 3.5+
- TypeScript 5+
# Clone the repository
git clone https://github.com/codeparl/form-builder.git
cd form-builder
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Build for production
pnpm build
# Run tests
pnpm test
# Lint code
pnpm lint
src/
βββ components/ # Vue components
β βββ FormBuilder.vue # Main form builder component
β βββ FormRenderer.vue # Form rendering component
β βββ fields/ # Field components
β βββ ...
βββ composable/ # Vue composables
βββ config/ # Configuration files
βββ css/ # Stylesheets
βββ data/ # Data and constants
βββ i18n/ # Internationalization
βββ types/ # TypeScript definitions
βββ index.ts # Main entry point
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Vue.js - The progressive JavaScript framework
- Naive UI - Vue component library
- Tailwind CSS - Utility-first CSS framework
- SortableJS - Drag and drop library
- π§ Email: hassan.mugabo@supernova-corp.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
See CHANGES.md for a list of changes and version history.
Made with β€οΈ by Hassan Mugabo