
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a great question about customizing reference field previews in Sanity Studio! When you're selecting a reference, you can show additional data beyond just the title by configuring the preview property in your schema.
The key is using the select and prepare functions in the referenced document's schema (not the field that references it). Here's how:
// In your author.js schema (the document being referenced)
export default {
name: 'author',
type: 'document',
fields: [
{name: 'name', type: 'string'},
{name: 'email', type: 'string'},
{name: 'bio', type: 'text'}
],
preview: {
select: {
title: 'name',
subtitle: 'email' // This shows up under the name!
}
}
}Now when you select this author in a reference field, you'll see the name as the main text and the email underneath.
You can use the prepare function to customize the display further:
preview: {
select: {
name: 'name',
email: 'email',
published: 'publishedPosts'
},
prepare({name, email, published}) {
return {
title: name,
subtitle: `${email} • ${published || 0} posts`
}
}
}You can even pull in data from nested references using dot notation:
preview: {
select: {
title: 'title',
authorName: 'author.name', // Access referenced author's name
categoryTitle: 'category.title'
},
prepare({title, authorName, categoryTitle}) {
return {
title: title,
subtitle: `by ${authorName} in ${categoryTitle}`
}
}
}The preview configuration lives in the schema of the document type being referenced, and it automatically applies wherever that document is shown - in lists, reference selectors, and search results. Check out the preview configuration documentation for more details and examples!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store