Live Playground

Try the Next Dynamic Forms library live in your browser! Experiment with different configurations and see the results in real-time.

Interactive Playground

The playground below uses Sandpack to provide a fully functional React environment where you can modify the code and see instant updates.

import React, { useState } from 'react';
import { DynamicForm } from '@benyue1978/next-dynamic-forms/core';
import { uiComponents } from './ui-components';
import { formConfig } from './form-config';
import { i18nAdapter } from './i18n';
import './global.css';

export default function App() {
  const [formData, setFormData] = useState({});
  const [currentStep, setCurrentStep] = useState(0);

  const nextStep = () => setCurrentStep(s => Math.min(s + 1, formConfig.steps.length - 1));
  const prevStep = () => setCurrentStep(s => Math.max(s - 1, 0));

  const handleSubmit = () => {
    console.log('Form submitted:', formData);
    alert('Form submitted successfully!');
  };

  return React.createElement('div', { className: 'form-container' },
    React.createElement('div', { className: 'form-card' },
      React.createElement('h1', { 
        style: { fontSize: '32px', fontWeight: 'bold', marginBottom: '24px', textAlign: 'center' }
      }, 'Multi-Step Registration Form'),
      
      
      React.createElement('div', { className: 'progress-container' },
        React.createElement('div', { className: 'progress-text' },
          `Step ${currentStep + 1} of ${formConfig.steps.length}`
        ),
        React.createElement('div', { className: 'progress-bar' },
          React.createElement('div', { 
            className: 'progress-fill',
            style: { width: `${((currentStep + 1) / formConfig.steps.length) * 100}%` }
          })
        )
      ),

      React.createElement(DynamicForm, {
        config: formConfig,
        currentStepIndex: currentStep,
        formData: formData,
        onDataChange: setFormData,
        onNext: currentStep === formConfig.steps.length - 1 ? handleSubmit : nextStep,
        onPrevious: prevStep,
        isFirstStep: currentStep === 0,
        isLastStep: currentStep === formConfig.steps.length - 1,
        uiComponents: uiComponents,
        i18n: i18nAdapter
      })
    )
  );
}

Available Demos

Explore our collection of interactive demos:

How to Use

  1. Edit code directly in the editor panel on the left
  2. See live updates in the preview panel on the right
  3. Navigate between files using the tabs
  4. Experiment freely - all changes are live!

Features

  • Real-time editing - See changes instantly as you type
  • Full React environment - Complete with all dependencies
  • Multi-file support - Edit multiple files in the same project
  • Error handling - Helpful error messages and debugging
  • Tailwind CSS - Styled components ready to go
  • Multiple files - Edit App.tsx, form-config.ts, package.json
  • Shareable configurations - Copy and share your creations
  • Next.js integration - Includes next-intl and server-side rendering