
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood news! You absolutely can filter and group by field values (not just documents) in Sanity Studio's Structure Tool. Let me give you concrete examples for your specific use cases.
You can use GROQ filters directly on field values like checkboxes, strings, arrays, etc. Here's how to handle your scenarios:
import {structureTool} from 'sanity/structure'
export default defineConfig({
plugins: [
structureTool({
structure: (S) =>
S.list()
.title('Products')
.items([
S.documentList()
.title('Available Products')
.filter('_type == "product" && isAvailable == true'),
S.documentList()
.title('Unavailable Products')
.filter('_type == "product" && isAvailable == false'),
S.divider(),
S.documentTypeListItem('product').title('All Products')
])
})
]
})For filtering products available in a specific week:
S.documentList()
.title('Products Available This Week')
.filter('_type == "product" && $week in availableWeeks')
.params({week: '19 July 2021 - 25 July 2021'})Or create a dynamic list with multiple week options:
const weeks = [
'19 July 2021 - 25 July 2021',
'26 July 2021 - 1 August 2021',
'2 August 2021 - 8 August 2021'
]
S.list()
.title('Products by Week')
.items([
...weeks.map(week =>
S.documentList()
.title(week)
.filter('_type == "product" && $week in availableWeeks')
.params({week})
)
])You can combine multiple conditions:
S.documentList()
.title('Available Products This Week')
.filter('_type == "product" && isAvailable == true && $week in availableWeeks')
.params({week: '19 July 2021 - 25 July 2021'})==, !=, >, <, in, match, etc. for different comparisons.params() to make filters dynamic and reusableThe confusion might be that some examples focus on reference fields (which are documents), but the same .filter() method works for any field type in your schema. You're just writing GROQ filters that evaluate field values directly!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store