npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@braine/form-builder1

v1.0.1

Published

A full-featured form builder for React applications

Downloads

9

Readme

Form Builder Package

A comprehensive, production-ready form builder for React applications with drag-and-drop functionality, conditional logic, multi-page support, and extensive field types.

Features

🚀 Core Capabilities

  • Drag & Drop Interface: Intuitive form building with visual field arrangement
  • Multi-Page Forms: Support for complex forms with pagination and navigation
  • Conditional Logic: Show/hide fields based on user responses with visual logic builder
  • Rich Field Types: 20+ field types including text, choice, file upload, interactive elements
  • Schema Export/Import: JSON-based form definitions for easy portability
  • Form Validation: Built-in validation rules with custom error messages
  • Responsive Design: Works seamlessly across desktop, tablet, and mobile devices

📋 Supported Field Types

Basic Fields

  • Short Text, Long Text (Textarea), Number, Email, Phone, Password, URL
  • Date, Time, Color Picker
  • Slider/Range, Star Rating

Choice Fields

  • Dropdown (Select), Multi-Select, Radio Buttons, Checkboxes, Toggle Switch

File & Media

  • File Upload, Image Upload

Interactive Elements

  • Signature Field, Drawing Pad, Star Rating, Slider

Layout & Control

  • Section Headers, Paragraph Text, Page Breaks

🧠 Smart Features

  • Conditional Logic Engine: IF-THEN rules with multiple operators
  • Form Validation: Required fields, min/max length, pattern matching
  • Multi-Page Navigation: Previous/Next with progress tracking
  • Auto-Save: Optional localStorage persistence
  • Theme Support: Light/dark mode ready
  • TypeScript: Full type safety throughout

Installation

npm install @your-org/form-builder
# or
yarn add @your-org/form-builder

Quick Start

Form Builder (Editor)

import React from 'react';
import { FormBuilder } from '@your-org/form-builder';

function App() {
  const handleExport = (schema) => {
    console.log('Form Schema:', schema);
    // Save to database or file
  };

  const handleSchemaChange = (schema) => {
    // Real-time schema updates
    console.log('Schema updated:', schema);
  };

  return (
    <FormBuilder 
      onExport={handleExport}
      onSchemaChange={handleSchemaChange}
    />
  );
}

Form Renderer (Display)

import React from 'react';
import { FormRenderer } from '@your-org/form-builder';

function MyForm({ formSchema }) {
  const handleSubmit = (formData) => {
    console.log('Form submitted:', formData);
    // Process form submission
  };

  const handlePageChange = (pageIndex) => {
    console.log('User navigated to page:', pageIndex);
  };

  return (
    <FormRenderer
      schema={formSchema}
      onSubmit={handleSubmit}
      onPageChange={handlePageChange}
      initialValues={{}} // Pre-populate form
    />
  );
}

API Reference

FormBuilder Props

| Prop | Type | Description | |------|------|-------------| | initialSchema | FormSchema | Pre-load existing form schema | | onSchemaChange | (schema: FormSchema) => void | Real-time schema updates | | onExport | (schema: FormSchema) => void | Handle schema export | | className | string | Additional CSS classes |

FormRenderer Props

| Prop | Type | Description | |------|------|-------------| | schema | FormSchema | Form schema to render | | onSubmit | (values: Record<string, any>) => void | Form submission handler | | onPageChange | (pageIndex: number) => void | Page navigation callback | | initialValues | Record<string, any> | Pre-populate form fields | | className | string | Additional CSS classes |

FormSchema Structure

interface FormSchema {
  id: string;
  title: string;
  description?: string;
  pages: FormPage[];
  fields: Record<string, FormField>;
  settings: FormSettings;
  version: string;
  createdAt: string;
  updatedAt: string;
}

Field Types & Configuration

Text Fields

{
  type: 'text' | 'textarea' | 'email' | 'phone' | 'password' | 'url',
  label: 'Field Label',
  placeholder: 'Enter text...',
  required: true,
  validation: [
    { type: 'required', message: 'This field is required' },
    { type: 'minLength', value: 3, message: 'Minimum 3 characters' }
  ]
}

Choice Fields

{
  type: 'select' | 'radio' | 'checkbox',
  label: 'Choose Options',
  options: [
    { id: '1', label: 'Option 1', value: 'option1' },
    { id: '2', label: 'Option 2', value: 'option2' }
  ]
}

Interactive Fields

{
  type: 'slider',
  label: 'Rate this',
  settings: {
    min: 0,
    max: 100,
    step: 1
  }
}

Conditional Logic

Basic Conditions

{
  conditionalLogic: [{
    id: 'logic1',
    operator: 'AND',
    conditions: [{
      fieldId: 'user_type',
      operator: 'equals',
      value: 'premium'
    }],
    actions: [{
      type: 'show',
      targetFieldId: 'premium_features'
    }]
  }]
}

Supported Operators

  • equals, notEquals
  • contains, notContains
  • greaterThan, lessThan
  • isEmpty, isNotEmpty

Available Actions

  • show / hide - Control field visibility
  • enable / disable - Control field interaction
  • setValue - Set field values programmatically

Multi-Page Forms

Page Configuration

{
  pages: [
    {
      id: 'page1',
      title: 'Personal Information',
      description: 'Tell us about yourself',
      fields: ['name', 'email', 'phone']
    },
    {
      id: 'page2', 
      title: 'Preferences',
      description: 'Your preferences',
      fields: ['interests', 'notifications']
    }
  ]
}

Navigation Settings

{
  settings: {
    navigation: {
      showProgress: true,      // Show progress bar
      allowBackward: true      // Allow previous page navigation
    }
  }
}

Advanced Usage

Custom Validation

const customValidation = {
  type: 'pattern',
  value: '^[A-Z]{2}[0-9]{4}$',
  message: 'Format must be XX0000'
};

Form State Management

import { useFormBuilderStore, useFormStore } from '@your-org/form-builder';

function CustomComponent() {
  const { schema, updateField } = useFormBuilderStore();
  const { formValues, updateFormValue } = useFormStore();
  
  // Access and modify form state
}

Styling & Theming

The package uses Tailwind CSS for styling. You can customize the appearance by:

  1. CSS Custom Properties: Override color schemes
  2. Tailwind Configuration: Extend default theme
  3. Custom CSS Classes: Use the className prop
/* Custom theme variables */
:root {
  --form-primary: #3B82F6;
  --form-secondary: #10B981;
  --form-background: #F9FAFB;
}

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import type { 
  FormSchema, 
  FormField, 
  ConditionalLogic,
  ValidationRule 
} from '@your-org/form-builder';

Browser Support

  • Chrome 80+
  • Firefox 75+
  • Safari 13+
  • Edge 80+

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see LICENSE file for details.

Changelog

v1.0.0

  • Initial release with full form builder functionality
  • Drag & drop interface
  • Multi-page support
  • Conditional logic engine
  • 20+ field types
  • TypeScript support
  • Comprehensive validation system