Getting Started

This guide walks you through building your first React form.

The live example on this page is the exact configuration shown below, rendered with the docs demo kit (Radiant UI styling).

Live example

Your Information

Get in touch with our team

More live React forms, including one built from copied shadcn source: React Forms.

1. Create a Form Engine

Install the form elements and, when using a supplied visual recipe, the recipe source from the Schema Engine shadcn registry:

pnpm dlx shadcn@latest add andeeplus/schema-engine/schema-form andeeplus/schema-engine/schema-engine-form-recipes

The recipes copy their stylesheet with them. Import it once in your global stylesheet, after Tailwind and into the components layer (see View recipes):

@import 'tailwindcss';
@import './components/schema-engine/forms/recipes/recipes.css' layer(components);
@import './components/ui/schema-engine/components/controls.css';

The path is relative to your global stylesheet: ./components/schema-engine/forms/recipes/recipes.css from a Vite src/index.css, ../components/schema-engine/forms/recipes/recipes.css from a Next.js app/globals.css. The second, unlayered import is the control height of the size appearance axis; it comes with the field primitive, and View recipes says why it is not layered.

Then import their generated registration barrels:

import { createFormEngine } from '@schema-engine/forms';
import { schemaFormRegistrations } from '@/components/schema-engine/forms/registrations';
import { schemaFormRecipeRegistrations } from '@/components/schema-engine/forms/recipes/registrations';

const formEngine = createFormEngine({ elements: schemaFormRegistrations, recipes: schemaFormRecipeRegistrations });

2. Configure Your Form

Create a JSON configuration — this page's live demo renders exactly this:

const formConfig: FormConfig = {
	id: 'basic-contact',
	title: 'Contact Us',
	description: 'Get in touch with our team',
	steps: [
		{
			id: 'details',
			title: 'Your Information',
			elements: [
				{
					$type: 'input',
					id: 'name',
					name: 'name',
					label: 'Full Name',
					inputType: 'text',
					rules: [
						{
							type: 'required',
							message: 'Name is required'
						}
					]
				},
				{
					$type: 'input',
					id: 'email',
					name: 'email',
					label: 'Email Address',
					inputType: 'email',
					rules: [
						{
							type: 'required',
							message: 'Email is required'
						},
						{
							type: 'email',
							message: 'Invalid email format'
						}
					]
				},
				{
					$type: 'textarea',
					id: 'message',
					name: 'message',
					label: 'Message',
					rows: 5
				}
			]
		}
	],
	view: {
		$type: 'card',
		shell: {
			appearance: {
				size: 'default',
				surface: 'elevated'
			}
		}
	}
};

When the form is authored in TypeScript next to your engine (not loaded from JSON), use engine.defineForm() for compile-time checks. See Authoring modes.

3. Render the Form

import { FormEngineProvider, FormRenderer } from '@schema-engine/forms-react';

function ContactForm() {
	const handleSubmit = (data) => {
		console.log('Form submitted:', data);
	};

	return (
		<FormEngineProvider engine={formEngine}>
			<FormRenderer config={formConfig} onSubmit={handleSubmit} />
		</FormEngineProvider>
	);
}

Next Steps