How to configure inline types in Portable Text block array?

1 replies
Last updated: May 11, 2022
When adding types to a portable text block array, they always seem to be placed on a new line instead of inline (between text on the same line).But in the docs there’s a picture of a symbol that indicates otherwise. How do I configure this?

See the “Author reference” in the image:
AI Update

To configure inline objects (like an author reference) in Portable Text that appear within the text line rather than as separate blocks, you need to use the of property within the block type definition itself, not at the array level.

The key difference is:

  • Block-level objects (new lines): Added to the array's of property
  • Inline objects (same line as text): Added to the block's of property

Here's how to configure inline objects:

{
  title: 'Rich text',
  type: 'array',
  of: [
    {
      type: 'block',
      // Inline objects go here inside the block definition
      of: [
        {
          type: 'authorReference',
          name: 'author',
          title: 'Author',
          to: [{type: 'author'}]
        }
      ]
    }
  ]
}

For the author reference shown in the docs screenshot, you'd define it as an inline object like this:

{
  name: 'content',
  type: 'array',
  of: [
    {
      type: 'block',
      marks: {
        decorators: [
          {title: 'Strong', value: 'strong'},
          {title: 'Emphasis', value: 'em'}
        ],
        annotations: [
          // Annotations are also inline but for marking up text
          {name: 'link', type: 'object', fields: [{name: 'href', type: 'url'}]}
        ]
      },
      // Inline objects that appear as insertable items
      of: [
        {
          type: 'reference',
          name: 'author',
          title: 'Author Reference',
          to: [{type: 'author'}]
        }
      ]
    }
  ]
}

As mentioned in the block type documentation, these inline objects are useful for things like footnotes, ticker symbols, or sparklines that need to appear within the flow of text rather than breaking it into separate blocks.

The distinction is crucial:

  • Array-level of: Creates block-level insertions (new lines)
  • Block-level of: Creates inline insertions (within text)

This is the configuration that allows objects to appear inline with text, as shown in the documentation image you referenced.

Show original thread
1 reply
Found it! Apparently the “block” type accepts an “of”-array for those.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?