The object
field is a dynamic field type that creates a nested page in the CMS with the data it contains.
This can be used to create repeated data structures or group related data in the CMS.
For additional properties common to all Field types, check the Field type definition.
Set this to "object"
to use the Object Field.
The name of the field for internal use.
The fields to display in the object.
The templates to display in the object.
Available when list: true.
Choose a different reference key for the templates.
All properties marked as REQUIRED must be specified for the field to work properly.
Only one of fields
or templates
should be defined.
Importantly, there are two key ways to use the object type...
fields
, the object wraps its inner fields in a sub-window.This appears as above, but pressing the +
gives you the option to choose one of a set of options.
This visual block selector allows editors to select Templates with images as well as text.
To enable the visual block selector, the visualSelector
property must be true. In the editor, this also opens a new window for template selection.
To get images for a certain template, you need to provide the image with the template's ui.previewSrc
property. This is a URL, or relative to your public folder as defined in the TinaCMS configuration.
const showcaseTemplate: Template = {label: 'Showcase',name: 'showcase',ui: {previewSrc: '/img/blocks/features.png',},fields: [//...],};
By default, object lists label each element with the Template label
or the object's label
+ " Item"
.
If you have a number of objects in the list, this can be customised per element with the itemProps
function property.
fields
templates
When using the templates property, your document stores each chosen template with the key, _template
.
---farm:- name: Tina_template: llama- name: Napoleon_template: farmer---
You can customise this with the templatesKey
property – the given key instead.
{label: "Testimonial",name: "testimonial",type: "object",fields: [{label: "Author",name: "author",type: "string"},{label: "Quote",name: "quote",type: "string",ui: {component: "textarea"}}]}
{label: "Page Blocks",name: "pageBlocks",type: "object",list: true,templates: [{label: "CTA",name: "cta",fields: [...]},{label: "Testimonial",name: "testimonial",fields: [...]}]}
Number, boolean, datetime, reference and rich-text field types can be used as the sole field of an object to create a list of one of those types.
{label: "Author List",name: "authorList",type: "object",list: true,fields: [{label: 'Author',name: 'author',type: 'reference',collections: ['author'],},]}
This example uses both templates and fields.
featureItem
objects stores an object array { headline, description, buttons }
.featureBlock
array is also an object list, with 3 options to choose from (Templates).import type { Template, TinaField } from 'tinacms';export const featuresTemplate: Template = {label: 'Feature Block',name: 'featureBlock',fields: [{name: 'featureItem',label: 'Feature Items',type: 'object',list: true,ui {itemProps: (item) => {return { label: item?.headline };},},fields: [{ name: 'headline', label: 'Headline', type: 'string' },{name: 'description', label: 'Description',type: 'string', ui: { component: 'textarea' }},{name: 'buttons',label: 'Buttons',list: true,type: 'object',ui: {visualSelector: true,itemProps: (item) => {return { label: item?.label };},},templates: [actionsButtonTemplate as Template,codeButtonTemplate as Template,modalButtonTemplate as Template],},] as TinaField[],},],};
When a new item is added to the list, it will be created with these defaultItem
values.
{label: "Testimonials",name: "testimonials",type: "object",list: true,defaultItem: {author: "Judith Black",role: "CEO",quote: "Lorem ipsum dol..."}fields: [{name: "author",type: "string"},{name: "role",type: "string"},{name: "quote",type: "string"ui: {component: "textarea"}}]}
Setting templateKey here changes our saved data to the below, where the key defining the template has been set to "type"
.
{name: "farm",type: "object",list: true,templateKey: "type",templates: [{name: "llama",fields: [{name: "name",type: "string",},],},{name: "farmer",fields: [{name: "name",type: "string",},],},],},
---farm:- name: Tinatype: llama- name: Napoleontype: farmer---
© TinaCMS 2019–2025