Complete guide to configuring the template builder component.
Document options
Control which document is loaded and how users interact with it:
Editing mode - Users can edit document content and insert fields.
Viewing mode - Read-only document display, fields can still be inserted.
Changing mode at runtime switches between editing and viewing without recreating the editor: no scroll jump or content flash:
Field system
Available fields
Define which fields users can insert:
Field types
Tag fields with a fieldType to distinguish roles:
Color-code fields in the document and sidebar with fieldColors:
Each color controls the field’s border and label in the document. The sidebar badges match automatically. Custom field types beyond owner and signer work the same way: just add them to fieldColors.
You can also import @superdoc-dev/template-builder/field-types.css directly and use CSS variables instead. The fieldColors prop is the recommended approach: no extra imports needed.
The fieldType value flows through all callbacks (onFieldInsert, onFieldsChange, onExport, etc.) and is stored in the SDT tag metadata.
Preset block content
Use presetContent to prefill block fields with a structure such as a table or list:
presetContent is passed into the existing block insertion command. For mode: "inline" fields, presetContent is ignored.
presetContent.json is recommended when you need the most reliable preservation of structure, semantics, and editor-compatible styling.
- With
presetContent.html, include required attributes and inline styles explicitly so the HTML parser can map them into node attributes.
Field creation
Allow users to create new fields while building templates:
When enabled, the field menu shows a “Create New Field” option with inputs for name, mode (inline/block), and field type (owner/signer).
Field locking
Make fields read-only so end users can’t edit their content:
Per-field lockMode overrides defaultLockMode. The default field creation form includes a “Locked” checkbox that sets contentLocked.
Template authors can always delete and manage fields regardless of lock mode: locking only affects end users interacting with the document. For advanced use cases, see lock modes.
Linked fields
When a user selects an existing field from the “Existing Fields” section in the menu, a linked copy is inserted. Both instances share a group ID and stay in sync.
The menu automatically groups existing fields and shows the count. When the last field in a group is deleted, the remaining field’s group tag is removed.
Trigger pattern
Change what opens the field insertion menu:
Replace the default field menu entirely:
The component handles trigger detection, filtering, and positioning. You render the UI.
Position and visibility
Omit list prop entirely to hide the sidebar.
Custom list component
Replace the default sidebar:
Control the document editing toolbar:
Event handlers
Field lifecycle events
Selection and interaction
Export event
Document ready
Telemetry
Telemetry is enabled by default with source: 'template-builder' metadata. You can override or extend the defaults:
To disable telemetry:
For more details on how telemetry works, see the Telemetry page.
License key
Pass licenseKey to identify your organization in telemetry:
The key is used solely for organization identification. It does not enable or disable any features, and nothing is blocked if a usage quota is reached. The key is forwarded to the underlying SuperDoc instance.
Complete example
Putting it all together:
Styling
The component uses CSS classes you can target:
Import superdoc/style.css for proper rendering. Optionally import @superdoc-dev/template-builder/field-types.css for field type color-coding.