Blocks field

The blocks field is similar to the array field in that you can create "Add one more" scenarios, but with the difference that it lets you define a separate field schema for each instance.

Usage example

links: fields.blocks(
  {
    // First block option is a link to a Page
    page: {
      label: 'Page',
      schema: fields.relationship({
        label: 'Page',
        collection: 'pages',
      }),
    },
    // Second block option is a link to a URL
    url: {
      label: 'URL',
      schema: fields.text({ label: 'URL' }),
    },
  },
  { label: 'Links' }
),

Screencast walk-through

This segment of the Keystatic Mini-Course on YouTube may help understand how the blocks field works:


Type signature

Find the latest version of this field's type signature at: https://docsmill.dev/npm/@keystatic/core@latest#/.fields.blocks