Changing the behavior of New Document and Action buttons in Studio v3.

4 replies
Last updated: Oct 4, 2022
I'm testing out the new Studio v3, and I'm trying to change the
__experimental_actions__: ["update", "publish"]
field that's suggested to use when you're creating site settings for instance. How do I emulate the same behavior in V3?
Oct 4, 2022, 11:42 AM
If its still experimental, Iโ€™m out ๐Ÿ˜…
Should be a core feature to create singleton items!
Oct 4, 2022, 1:07 PM
As I understand it
is depreciated.Instead you override how the New Document and Action buttons appear in your
.Here is how I did it.

import {createConfig, DocumentBadgeComponent, DocumentBadgesResolver, isDev} from 'sanity'
import {deskTool, StructureBuilder} from 'sanity/desk'
import {schemaTypes} from './schemas'
import {visionTool} from '@sanity/vision'
import {media} from 'sanity-plugin-media'
import {structure, defaultDocumentNode} from './structure/structure'

import {CustomPublishAction} from './actions/CustomPublishAction'
import {HelloWorldBadge} from './actions/HelloWorldBadge'

import { colorInput } from "@sanity/color-input";

const devOnlyPlugins = [ visionTool() ]

// array of document types that only publishing should be allowed on.
// makes no sence to have 'create' or 'duplicate'
export const publishOnlyDocuments = ['homePage', 'siteSettings']

// Determins the actions that appear in the Publish bar
const actions = (actions: any, {schemaType}: any) => {
  // deconstruct all actions so we can order them if required.
  const [publish, discardChanges, unPublish, duplicate, deleteDocument, ...anyOtherActions] =

  // if this document is in the  publishOnlyDocuments then we don't want
  // return only publish (or schedule if it is there)
  if (publishOnlyDocuments.includes(schemaType)) {
    return [publish]

  return [
    CustomPublishAction, // Example action which intercepts the current publish action.

// Determins the Document badges that appear in the Publish bar.
const badges = (badges: any) => {
  const [...otherBadges] = badges
  return [...otherBadges, HelloWorldBadge]

// Determins the New Documents Types that appear when clicking the New Document Button . 
const newDocumentOptions = (newDocumentOptions: any) => {  
  const filteredNewDocumentOptions = newDocumentOptions.filter((documentOption: any) => {
    // return only the documentTypes that are not publishOnlyDocuments
    return !publishOnlyDocuments.includes(documentOption.templateId)
  return filteredNewDocumentOptions

export default createConfig({
  name: 'default',
  title: 'WHATEVER',
  projectId: 'WHATEVER',
  dataset: 'production',

  document: {
    actions: actions,
    badges: badges,
    newDocumentOptions: newDocumentOptions,

  plugins: [
    // media(),
    ...(isDev ? devOnlyPlugins : []),

  schema: {
    types: schemaTypes,
Oct 4, 2022, 1:10 PM
user U
! You'll want to ask V3 questions here until general release.
Oct 4, 2022, 5:14 PM
Oh okay, thanks ๐Ÿ™‚ Will do.
Oct 4, 2022, 6:01 PM

Sanityโ€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?