How to select multiple items from a reference field dropdown in Sanity?

13 replies
Last updated: Jan 28, 2026
{ name:"category",
title:"Category",
type:"reference",
to: { type: "category" },

inputComponent: conditionalFields,
options:{

condition: (document, parent) => parent.articleType != "shortStories"
},
},
I want to select multiple items from the dropdown is it possible?
AI Update

Yes! To select multiple items from a dropdown, you need to change your field from a single reference type to an array of references. Here's how to modify your schema:

{
  name: "category",
  title: "Category",
  type: "array",  // Changed from "reference" to "array"
  of: [
    {
      type: "reference",
      to: { type: "category" }
    }
  ],
  inputComponent: conditionalFields,
  options: {
    condition: (document, parent) => parent.articleType != "shortStories"
  }
}

The key changes are:

  1. Change type to "array" - This makes the field hold multiple items
  2. Add an of property - This defines what types can be in the array (in your case, references to category documents)

This will give you a multi-select interface where you can add multiple category references. Users can click to add categories, reorder them via drag-and-drop, and remove them individually.

The array field type in Sanity is specifically designed for storing orderable collections of items, and it's the standard way to handle multiple selections. Each selected item automatically gets a unique _key property that Sanity uses to track items.

If you need to query these multiple references later in GROQ, you can use array operations like:

*[_type == "yourDocType"] {
  title,
  "categories": category[]->title
}

The []-> syntax dereferences all items in the array, giving you the full category documents.

Show original thread
13 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?