Disable normal text or set heading 2 as default in Sanity rich text editor
Yes, you can definitely customize the Portable Text editor to disable "normal text" or make a specific heading the default! Here's how to do it:
Remove Normal Text Style
To disable the "normal" paragraph style from your Portable Text editor, you need to configure the styles array in your block type schema. Simply exclude normal from the styles array:
export default {
name: 'content',
type: 'array',
title: 'Content',
of: [
{
type: 'block',
styles: [
{ title: 'Heading 2', value: 'h2' },
{ title: 'Heading 3', value: 'h3' },
{ title: 'Quote', value: 'blockquote' }
]
}
]
}In this configuration, users can only choose from H2, H3, and blockquote styles - no normal paragraph option will appear.
Make Heading 2 the Default
While you can't technically set a default style through configuration alone (the editor defaults to normal), you can work around this in a couple of ways:
Option 1: Use Initial Value Templates
You can create an initial value template that pre-populates content with H2 blocks:
export default {
name: 'content',
type: 'array',
title: 'Content',
of: [
{
type: 'block',
styles: [
{ title: 'Heading 2', value: 'h2' },
// other styles...
]
}
],
initialValue: [
{
_type: 'block',
style: 'h2',
children: [{ _type: 'span', text: '' }]
}
]
}Option 2: Only Include H2 as the Single Style
If H2 is the only style in your array, it becomes the de facto default since it's the only option:
styles: [
{ title: 'Heading 2', value: 'h2' }
]Important Considerations
Keep in mind that the styles configuration in Sanity's Portable Text editor is similar to what you'd configure in TinyMCE's block_formats or CKEditor's heading options, but it's defined in your schema rather than in the editor configuration itself.
The Portable Text editor configuration documentation provides more details on customizing styles, decorators, and other editor features. You can also check out the customization guide for styling how blocks appear in the editor itself.
Show original thread8 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.