How to reorder documents by dragging in Sanity document lists?

12 replies
Last updated: Apr 19, 2020
Is there a way to have the list of documents be reordered by dragging them up or down. Is the only way to order the documents by putting a order ID and then changing the orderBY to that ID either asc or des
AI Update

Good news! You're not limited to just using an order ID field. Sanity has an official plugin called Orderable Document List that lets you drag and drop documents to reorder them directly in the Studio.

How to Use Drag-and-Drop Ordering

Install the plugin with:

npm i @sanity/orderable-document-list

Once installed and configured, you'll be able to manually reorder documents by dragging them up or down in your document list. The plugin manages this behind the scenes using an orderRank field, so you don't have to manually maintain order IDs yourself.

When to Use Each Approach

Use the Orderable Document List plugin when:

  • You want a simple, visual way to order documents
  • Your content editors need to manually control ordering
  • You have small to medium-sized document collections

Use a manual order field with orderBy when:

  • You need different ordering schemes in different contexts
  • You want to programmatically control ordering
  • You need more complex sorting logic

The plugin is definitely the more user-friendly option for most cases where you need manual ordering. It's maintained by the Sanity team and works well with Studio v3. The ordering it creates can also be queried from your frontend applications, so the order you set in Studio will be reflected on your site.

Before this plugin existed, people had to use workarounds like wrapper documents with reference arrays or manual order fields, but the plugin streamlines the whole process considerably. You can find more details in the plugin documentation.

Show original thread
12 replies
more context?
If its in the document list, you can use the
deskStructure
to order them, group them, etc
For the list of Flooring Tiles, is there a way to have the user drag and reorder them? Instead of having to assign ID's to each and reorder by that manually.
why would they want to reorder them? does that somehow change the frontend?
you can use the
orderings
to set up your own custom orders
but there is no “drag and drop” option… again, not really sure what the would accomplish
ok no problem, I was using datoCMS for another project, and you could drag and drop orders of projects which would update a order property in graphql which was super helpful to have a certain item show up higher on the page if you wanted to feature it first
it will work without drag and drop to tho, thanks
I just know, down the road some is gonna ask, how to we put Hardwood infront of Tile so on. So I need it to be simple of enough to change that ui from sanity
i don’t think changing the
orderings
actually changes how you get them in graphql
that could be done in the query itself though
for
sort
just choose what you want to sort by, pretty straight forward

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?