How to control entity titles in Sanity (e.g., "row 1", "row 2")?

5 replies
Last updated: Dec 2, 2025
Hi everyone! Short question: how do you control entities titles? For example, I want all the rows to have a “row 1”, “row 2" etc titles. If there is no title, entities have strange names based on values. Where to read about this? Would really appreciate your help!
AI Update

You're looking for preview configuration in Sanity! This controls how documents and objects appear in lists throughout the Studio.

By default, Sanity tries to automatically generate preview titles from your document fields, which can result in those strange names you're seeing. You can take full control using the preview property in your schema.

Here's how to set up basic preview configuration:

{
  name: 'row',
  type: 'object',
  preview: {
    select: {
      title: 'name',  // Use the 'name' field as the title
      subtitle: 'description'
    }
  }
}

If you need custom logic (like combining multiple fields or formatting), use the prepare function:

preview: {
  select: {
    firstName: 'firstName',
    lastName: 'lastName'
  },
  prepare({firstName, lastName}) {
    return {
      title: `${firstName} ${lastName}`,
      subtitle: 'Customer'
    }
  }
}

For your specific case of wanting "Row 1", "Row 2" numbering, this is trickier since the standard preview configuration doesn't have built-in access to the array index. You have a few options:

  1. Add an explicit number field to your row object and use that in the preview
  2. Use a custom input component that can access the array context and display custom numbering
  3. Set up an initialValue function that automatically numbers rows as they're created

The simplest approach is option 1 - add a field to store the row number:

{
  name: 'row',
  type: 'object',
  fields: [
    {
      name: 'rowNumber',
      type: 'number',
      hidden: true,
      readOnly: true
    },
    // your other fields
  ],
  preview: {
    select: {
      rowNumber: 'rowNumber'
    },
    prepare({rowNumber}) {
      return {
        title: `Row ${rowNumber || '?'}`
      }
    }
  }
}

You can read more about this in the official preview configuration documentation and check out this guide on creating richer array item previews for more advanced examples.

Show original thread
5 replies

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?