
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on your question about customizing the button behavior to open a modal before proceeding to the edit screen, you'll want to look into Document Actions. These are the customizable toolbar actions in Sanity Studio that control what happens when you interact with documents.
You can create a custom document action that:
Here's the general approach:
1. Create a custom document action resolver in your Studio configuration. Add this to your sanity.config.ts:
import {defineConfig} from 'sanity'
export default defineConfig({
// ... other config
document: {
actions: (prev, context) => {
// Add your custom action
return [...prev, MyCustomAction]
}
}
})2. Build your custom action with a dialog component. Your action can return a dialog property that renders a modal:
import {useState} from 'react'
const MyCustomAction = (props) => {
return {
label: 'Custom Edit',
icon: YourIcon,
onHandle: () => {
// This opens your modal
props.onComplete()
},
dialog: {
type: 'modal',
content: YourModalComponent
}
}
}3. In your modal component, handle the selection logic and then programmatically navigate to the edit screen or trigger the appropriate action based on the user's choice.
You can also filter or replace existing actions if you want to modify the default behavior of built-in buttons like "Edit". For example, you might want to intercept the default edit action for certain document types:
actions: (prev, context) => {
if (context.schemaType === 'yourDocType') {
return prev.map(action =>
action.name === 'edit' ? YourCustomAction : action
)
}
return prev
}Check out the full Document Actions API documentation and this guide on custom document actions for detailed examples and implementation patterns.
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