
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI'd be happy to help you create a button in Sanity Studio! Since you mentioned "here" without more context, let me cover the most common scenarios for adding buttons:
The most typical place to add a button is in the document actions area (top-right of a document). You can create a custom document action that appears as a button in the actions menu.
Here's a quick example:
1. Create your action component (actions/HelloWorldAction.js):
export function HelloWorldAction(props) {
return {
label: 'Hello world',
onHandle: () => {
// Your button logic here
window.alert('đź‘‹ Hello from custom action')
}
}
}2. Register it in your sanity.config.ts:
import {defineConfig} from 'sanity'
import {HelloWorldAction} from './actions/HelloWorldAction'
export default defineConfig({
// ... other config
document: {
actions: (prev) => [...prev, HelloWorldAction]
}
})This adds your button to the document actions dropdown menu.
Here's a document action that actually modifies the document:
import {useDocumentOperation} from 'sanity'
export function SetAndPublishAction(props) {
const {patch, publish} = useDocumentOperation(props.id, props.type)
return {
label: 'Set Date & Publish',
onHandle: () => {
// Update a field
patch.execute([{set: {publishedAt: new Date().toISOString()}}])
// Then publish
publish.execute()
props.onComplete()
}
}
}Could you provide more details about where you'd like the button and what it should do? That way I can give you more specific guidance!
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