This Friday: Hear from Sanity + Vercel experts on AI and better personalization in e-commerce

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

13 repliesLast updated: Nov 30, 2025

{ 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:

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

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