
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeWhen creating custom types in Sanity, you can add options to your type definition and access them within your schema. Here's how it works:
Options are defined within an options object in your schema definition. For example:
{
type: 'object',
name: 'localeBlock',
title: 'Localized Block',
options: {
collapsible: true,
collapsed: false,
columns: 2,
modal: {
type: 'dialog',
width: 'medium'
}
},
fields: [
// your fields here
]
}According to the object type documentation, you can use these options:
collapsible: Set to true to make fields collapsible (default at depth 3)collapsed: Set to true to start with fields collapsed (requires collapsible: true)columns: Number of columns in a grid layout for inputsmodal: Controls modal rendering with type ('dialog' or 'popover') and width propertiesIf you need to access options programmatically within custom components or input components, you can access them through the schema type context:
// In a custom input component
const MyCustomInput = (props) => {
const options = props.schemaType.options
// Access specific options
const isCollapsible = options?.collapsible
const columnCount = options?.columns
// Use them in your component logic
return (
// your component JSX
)
}Remember that options can be defined at both the type level (affecting all instances) and when you use the type in a field:
// In your schema
fields: [
{
name: 'myLocaleBlock',
type: 'localeBlock',
options: {
// These override the type-level options for this specific field
collapsed: true
}
}
]The field-level options will override type-level options when both are present. This gives you flexibility to set defaults at the type level while customizing behavior for specific field instances.
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