How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Render custom block type as inline text with special formatting

20 repliesLast updated: Nov 30, 2025

if I have a
type
in my blockContent that I’d like to render as sort of inline text just with some special formatting - is that possible? I originally made it an annotation but that’s clearly to lightweight. I want to manage these as documents but as a doc, it’s a full-width element in the editor. Would like it to show jsut like this
AI Update

Yes, you can absolutely render a custom type as inline text with special formatting! What you need is an inline block object, which is different from both annotations and regular block-level objects.

Here's how to set it up:

In your schema, add your custom type to the of array inside the block definition (not at the array level):

{
  name: 'content',
  type: 'array',
  of: [
    {
      type: 'block',
      // This is the key - put inline objects in the block's 'of' property
      of: [
        {
          type: 'myInlineType',
          name: 'myInlineType',
          title: 'My Inline Type',
          fields: [
            // Your document fields here
            {name: 'value', type: 'string'},
            {name: 'metadata', type: 'object', fields: [...]}
          ]
        }
      ]
    }
  ]
}

The critical difference is:

This way, your custom type will appear inline in the editor (you can insert it via the Insert menu while editing text), but you still get the full power of managing it as a proper document with all the fields you need.

You can also customize how it renders in the Studio by adding a custom inlineBlock component to control its appearance in the editor.

When rendering on the front end, you'll need to handle this inline object type in your Portable Text serializer to display it with your special formatting.

Show original thread
20 replies

Was this answer helpful?

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.

Related contributions