Theming & Presets
Customize form appearance with themes and presets.
FieldCraft uses a theme object that maps to CSS custom properties. Pass a built-in preset or define your own — every color, font, radius, and spacing value is customizable.
Using a Preset
Available Presets
| Preset | Import | Description |
|---|---|---|
| Clean | cleanPreset | Teal primary, comfortable spacing, subtle design. The default. |
| Modern | modernPreset | Indigo primary, larger fonts, centered layout, generous spacing. |
| Dark | darkPreset | Cyan primary on dark background, dark surface colors. |
| High Contrast | highContrastPreset | Blue primary, large fonts, spacious layout, high contrast borders. |
| Clinical | clinicalPreset | Sky blue primary, minimal styling, bordered sections. |
| Playful | playfulPreset | Pink primary, fully rounded corners, warm background. |
Theme Structure
A FormEngineTheme has five sections:
Custom Theme
Spread a preset and override the values you want:
CSS Custom Properties
The theme is converted to CSS custom properties at runtime via themeToCssVars(). All properties use the --fe- prefix and are also aliased to shadcn/ui variable names for compatibility.
Color Variables
| FieldCraft Variable | shadcn Alias |
|---|---|
--fe-color-primary | --primary |
--fe-color-primary-foreground | --primary-foreground |
--fe-color-secondary | --secondary |
--fe-color-error | --destructive |
--fe-color-surface | --card, --popover, --accent |
--fe-color-background | --background, --muted |
--fe-color-text | --foreground |
--fe-color-text-muted | --muted-foreground |
--fe-color-border | --border, --input |
--fe-color-border-focus | --ring |
Typography Variables
| Variable | Description |
|---|---|
--fe-font-family | Font stack |
--fe-font-scale | Base size multiplier |
--fe-font-question | Question label size |
--fe-font-label | Input label size |
--fe-font-help | Help text size |
--fe-font-body | Body text size |
Shape & Spacing Variables
| Variable | Mapped From |
|---|---|
--fe-radius / --radius | shape.radius (none→0px, sm→4px, md→8px, lg→12px, full→9999px) |
--fe-radius-input | shape.inputRadius |
--fe-radius-button | shape.buttonRadius |
--fe-radius-card | shape.cardRadius |
--fe-spacing-base | spacing.base (px) |
--fe-spacing-section-gap | spacing.sectionGap (px) |
--fe-spacing-field-gap | spacing.fieldGap (px) |
ThemeProvider
If you're building a custom UI with hooks instead of FormEngineRenderer, wrap your form in FormEngineThemeProvider:
Overriding with CSS
Since all styling flows through CSS variables, you can override any value in a plain stylesheet: