How to use documentTypeList without the create button in Sanity?
Yes, absolutely! You can hide the create button on a documentTypeList while keeping the search and ordering features by using the .initialValueTemplates([]) method.
Based on your use case, here's how to modify your structure:
S.listItem()
.title('Blog Posts by Category')
.child(
S.documentTypeList('blogCategory')
.title('Blog Categories')
.initialValueTemplates([]) // <-- This removes the create button
.child((categoryId: string) =>
S.documentList()
.title('Blog Posts')
.filter('_type == "blog" && references($categoryId)')
.params({ categoryId })
)
)The key is adding .initialValueTemplates([]) to your documentTypeList. By passing an empty array, you're telling Sanity not to show any document creation options for that specific list, which effectively hides the "+" button.
This approach is perfect because:
- It only affects the specific
documentTypeListwhere you add it - Search and ordering features remain fully functional
- You don't need to create custom components
- Other document lists in your structure keep their create buttons
If you want to learn more about how initial value templates work, check out the Initial Value Templates documentation. There's also a comprehensive Structure Builder API reference that covers all the available methods for the sanity/structure package.
Show original thread11 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.