Studio

Custom document badges

Define a custom document badge and register it in document.badges to show it in the studio.

A document badge (DocumentBadgeComponent) is a small UI component that indicates the status of a document. It appears in the studio next to the document toolbar actions. By default, the Structure tool shows a Live badge on documents whose schema type has liveEdit enabled, and a badge on singleton documents.

Depending on how you implement your workflows, you may want to control which badges appear here. For example, if your workflow includes a review step, you might display a "Pending review" badge.

Custom badges can be combined with custom document actions

Learn more about creating custom workflows →

Getting started

More details in the document badge reference documentation →

To implement your own custom badge, complete two steps:

  • Create a function that defines the badge
  • Register the badge and decide which documents display it

Here's how:

Define a custom badge

export function HelloWorldBadge(props) {
  return {
    label: 'Hello world',
    title: 'Hello I am a custom document badge',
    color: 'success',
  }
}

Register a custom badge

Add your badge to the document.badges property in defineConfig.

import {defineConfig} from 'sanity'
import {HelloWorldBadge} from './HelloWorldBadge'

export default defineConfig({
  // ... rest of config
  document: {
    badges: [HelloWorldBadge],
  },
})

A static array, as in the example above, appends your custom badges to the list of existing badges, if any. These include the default badges provided by Sanity Studio and any badges added by plugins.

The property can also be defined with a callback function that returns an array of badge components. When using the callback option, it's your responsibility to make sure any existing badges are passed along. The callback receives the current array of badges as its first argument and a context object as its second. The context includes schemaType, documentId, and singleton (the singleton definition ID, if the document is a singleton), along with the workspace's projectId, dataset, schema, currentUser, and getClient. Each badge function receives the document's current edit state as props, including id, type, draft, published, and liveEdit.

import {defineConfig} from 'sanity'
import {HelloWorldBadge} from './HelloWorldBadge'

export default defineConfig({
  // ... rest of config
  document: {
    // Use info from the context to decide whether to add
    // the badge or return the current list unchanged
    badges: (prev, context) =>
      context.schemaType === 'movie' ? [HelloWorldBadge, ...prev] : prev,
  },
})

The next time you edit a document in the studio, your badge appears in the document toolbar:

Default and custom badges

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme