Fields
Object Field
A nested field for grouping related data or creating block-based content
A nested field that groups related data together. Can be used for single objects, lists, or block-based page builders with templates.
Usage
{
type: 'object',
name: 'author',
label: 'Author',
fields: [
{ type: 'string', name: 'name', label: 'Name' },
{ type: 'string', name: 'bio', label: 'Bio' },
],
}Options
| Property | Type | Description |
|---|---|---|
type | 'object' | Required. |
name | string | Field identifier. |
label | string | Display label in the editor. |
fields | Field[] | Nested fields. Use this OR templates. |
templates | Template[] | Block templates for page builders. Use this OR fields. |
list | boolean | Allow multiple items. |
ui.visualSelector | boolean | Show visual block picker for templates. |
ui.itemProps | (item) => { label } | Custom labels for list items. |
ui.defaultItem | object | Default values for new items. |
Type Signature
interface ObjectField {
type: 'object'
name: string
label?: string
list?: boolean
fields?: Field[]
templates?: Template[]
ui?: {
visualSelector?: boolean
itemProps?: (item: Record<string, unknown>) => { label?: string }
defaultItem?: Record<string, unknown>
}
}Examples
List of Objects
{
type: 'object',
name: 'testimonials',
label: 'Testimonials',
list: true,
fields: [
{ type: 'string', name: 'author', label: 'Author' },
{ type: 'string', name: 'quote', label: 'Quote', ui: { component: 'textarea' } },
],
}Page Blocks (Templates)
Allow editors to build pages from predefined block types:
{
type: 'object',
name: 'blocks',
label: 'Page Blocks',
list: true,
templates: [
{
name: 'hero',
label: 'Hero',
fields: [
{ type: 'string', name: 'heading' },
{ type: 'image', name: 'image' },
],
},
{
name: 'features',
label: 'Features',
fields: [
{ type: 'object', name: 'items', list: true, fields: [/* ... */] },
],
},
],
}With Visual Selector
Add preview images to the block picker:
{
type: 'object',
name: 'blocks',
label: 'Page Blocks',
list: true,
ui: { visualSelector: true },
templates: [
{
name: 'hero',
label: 'Hero',
ui: { previewSrc: '/img/blocks/hero.png' },
fields: [/* ... */],
},
],
}