Why do Articles have Editor/Preview tabs but other documents don't?
There's a simple explanation for this! The Editor/Preview tabs you're seeing in some documents are not automatic - they're configured through the Structure Builder API using defaultDocumentNode.
By default, all documents in Sanity Studio only show the Editor tab. The Preview (or any additional tabs) appear when you explicitly configure them using the getDefaultDocumentNode function in your structure configuration.
Here's what's likely happening in your setup:
For "Articles" (with tabs): Your structure configuration probably has something like this:
export const getDefaultDocumentNode: DefaultDocumentNodeResolver = (S, options) => {
if (options.schemaType === "article") {
return S.document().views([
S.view.form(),
S.view.component(PreviewComponent).title('Preview')
])
}
}For other documents (without tabs): They're using the default behavior, which only shows the form editor.
How to add tabs to your documents
You can configure document views in your sanity.config.ts by:
- Creating a
getDefaultDocumentNodefunction that returns different views usingS.document().views() - Adding it to your
structureToolconfiguration:
import {structureTool} from 'sanity/structure'
export default defineConfig({
plugins: [
structureTool({
defaultDocumentNode: getDefaultDocumentNode,
}),
],
})You can conditionally show preview tabs based on schemaType or documentId, which is why only certain document types have them.
For more details on setting this up, check out the Structure Builder documentation on creating custom document views.
Show original thread31 replies
Sanity – Build the way you think, not the way your CMS thinks
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.