Hide + button in Sanity nested documentList structure

12 replies
Last updated: Jan 27, 2026
I'm following the structure cheet sheet and I've the exact same use case as shown in this code. And I'm able to show blog by category. But at the top there is + button. It is behaving not as expected. When I click on it opens the new section on the right side with no documents and when I click on the + icon of this no documents list it opens add new blog page. I want to hide thay + icon.
Attaching an image for understanding that which + button I want to hide.


S.documentTypeListItem('post').title('Posts'),
S.documentTypeListItem('category').title('Categories'),
S.listItem()
  .title('Posts By Category')
  .child(
    S.documentTypeList('category')
      .title('Posts by Category')
      .child((categoryId) =>
        S.documentList()
          .apiVersion('2024-06-01')
          .title('Posts')
          .filter('_type == "post" && $categoryId in categories[]._ref')
          .params({categoryId}),
      ),
  )
AI Update

Looking at your code, the issue is that the nested S.documentList() in your "Posts By Category" structure doesn't specify which document types can be created, so it's showing a generic "+" button that leads to an empty creation menu.

To hide that "+" button, you need to pass an empty array to initialValueTemplates() on your documentList(). This tells Sanity that no documents should be creatable from that particular list:

S.listItem()
  .title('Posts By Category')
  .child(
    S.documentTypeList('category')
      .title('Posts by Category')
      .child((categoryId) =>
        S.documentList()
          .apiVersion('2024-06-01')
          .title('Posts')
          .filter('_type == "post" && $categoryId in categories[]._ref')
          .params({categoryId})
          .initialValueTemplates([]),  // Add this line to hide the + button
      ),
  )

The .initialValueTemplates([]) method controls which document creation templates are available in that specific list. By passing an empty array, you're telling the Structure Builder that no creation options should be shown, which effectively hides the "+" button.

This makes sense for your use case since you're showing a filtered list of posts based on category selection. Users should probably create posts from the main "Posts" list item instead, where they can properly set all fields including the category.

If you later decide you want to allow creating posts directly from the category view (with the category pre-populated), you could configure a custom initial value template that automatically sets the category reference based on the categoryId parameter.

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