Atlas Forms
Building the DesignComponent
The DesignComponent is the control's representation in the Form Studio palette and on the canvas when in design mode. It is a static, non-interactive thumbnail that helps form authors recognise the control type at a glance.
Props Contract
interface DesignComponentProps {
control: FormControl; // Default config (from plugin's defaultConfig)
}
// No value, onChange, onBlur β DesignComponent is purely visual
Two Use Cases
The DesignComponent appears in two places:
- Palette tile β Small thumbnail in the control palette, showing the icon and label
- Canvas preview β When a control is on the canvas in design mode, this renders inside the design overlay frame
Phone Input Design Component
import React from 'react';
import type { DesignComponentProps } from '@atlas-forms/types-js';
export const PhoneDesignComponent: React.FC<DesignComponentProps> = ({ control }) => (
<div className="design-preview phone-preview">
<label className="field-label">{control.label || 'Phone Number'}</label>
<div className="input-mockup">
<span className="flag-placeholder">πΊπΈ</span>
<span className="input-placeholder">+1 (555) 000-0000</span>
</div>
</div>
);
Design Best Practices
- Keep it simple β The design component is a thumbnail, not a full render. Show the shape and key visual elements only.
- Show the label β Always render
control.labelso form authors can read the field name on the canvas. - Use static/placeholder data β Never make API calls or use hooks that fetch data in the design component.
- Match the visual shape β The design component should look similar to the edit component so authors can recognise what they are dropping.
- Omit interaction β No click handlers, no focus states, no validation messages.
When to Omit DesignComponent
If you omit DesignComponent, Form Studio falls back to rendering EditComponent in static mode (no events). This works for most controls. Only provide a custom DesignComponent when the edit component is too heavyweight for design-mode rendering (e.g., it makes API calls on mount).