Docs
v1.4.1
GitHubSite
Pro / Theme editor

Theme editor

Visual theme customizer for FieldCraft forms. Edit colours, typography, spacing, and shape with live preview. Part of the Pro commercial package.

What it does

ThemeEditor is a standalone React component for visually customizing FieldCraft form themes. It outputs a FormEngineTheme object — the same format used by FormRenderer's theme prop.

The ThemeEditor is part of @squaredr/fieldcraft-pro, which requires a commercial licence.

Auto-inherit from host page

When rendered without an initialTheme prop, the ThemeEditor reads the current CSS custom properties from your host page (the standard shadcn/ui variables like --background, --primary, --foreground, etc.) and uses them as the starting theme. This means the editor opens with your app's actual theme, not a generic default.

The component also watches for dark/light mode changes on <html> (via data-theme attribute or dark class) and re-resolves the theme automatically.

import { ThemeEditor } from '@squaredr/fieldcraft-pro'

// No initialTheme needed — starts from your page's CSS variables
export default function ThemeDesignerPage() {
  return (
    <ThemeEditor
      onSave={async (theme) => {
        await fetch('/api/themes', {
          method: 'POST',
          body: JSON.stringify(theme),
        })
      }}
    />
  )
}

Features

FeatureDescription
Live previewA form renders in real-time as you adjust colours, typography, spacing, and shape.
Preset familiesFive families (Clean, Modern, Clinical, Playful, High Contrast) with light and dark variants (10 total).
Palette generatorGenerate harmonious colour palettes from a single primary colour.
CSS exportCopy the theme as CSS custom properties for use outside FieldCraft.
JSON exportExport the FormEngineTheme object for storage or import.
Comparison viewCompare two themes side-by-side.
Dark mode awarenessWatches for dark class or data-theme changes on <html> and re-resolves automatically.

Props

Core

PropTypeDefaultDescription
initialThemeFormEngineThemeAuto-resolved from host CSSInitial theme to load in the editor.
onChange(theme: FormEngineTheme) => voidCalled on every theme change.
onSave(theme: FormEngineTheme) => voidCalled when user clicks Save or presses Ctrl+S.
showPreviewbooleantrueShow the live form preview panel.

Layout

PropTypeDefaultDescription
heightstring | numberContainer height.
widthstring | numberContainer width.
classNamestringAdditional CSS class on root element.
toolbarExtraReactNodeExtra content rendered in the toolbar.

Editor chrome theme

PropTypeDefaultDescription
themeThemeEditorThemeControls the editor UI appearance (toolbar, panels, controls) — not the form preview. See below.

Editor chrome vs form theme

The ThemeEditor has two separate theme concepts:

  • Form theme (FormEngineTheme) — the theme being edited. This is what initialTheme, onChange, and onSave work with. It controls the form preview.
  • Editor chrome theme (ThemeEditorTheme) — the theme prop. This controls the appearance of the editor's own UI: toolbar, panels, controls, inputs.
import type { ThemeEditorTheme } from '@squaredr/fieldcraft-pro'

// ThemeEditorTheme controls the editor chrome
type ThemeEditorTheme = {
  background?: string;
  surface?: string;
  surfaceHover?: string;
  text?: string;
  textMuted?: string;
  textDim?: string;
  border?: string;
  borderStrong?: string;
  inputBackground?: string;
  accent?: string;
  accentForeground?: string;
}

Two built-in editor chrome presets are available:

import { ThemeEditor, themeEditorDarkPreset } from '@squaredr/fieldcraft-pro'

<ThemeEditor theme={themeEditorDarkPreset} onSave={handleSave} />

Using presets programmatically

Five preset families are available for use as starting themes:

import { ThemeEditor, PRESET_FAMILIES } from '@squaredr/fieldcraft-pro'

<ThemeEditor
  initialTheme={PRESET_FAMILIES.clinical.light}
  onSave={handleSave}
/>
FamilyKeyDescription
CleancleanMinimal, neutral colours, comfortable spacing.
ModernmodernContemporary styling with rounded corners.
ClinicalclinicalProfessional/medical. Clean lines, clinical feel.
PlayfulplayfulFriendly and colourful. Larger radii, warmer tones.
High Contrasthigh-contrastAccessibility-focused. Strong borders, large text.

Each family has .light and .dark variants:

PRESET_FAMILIES.modern.light  // FormEngineTheme
PRESET_FAMILIES.modern.dark   // FormEngineTheme
PRESET_FAMILIES.modern.label  // "Modern"

Next steps

On this page