
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYour current approach is actually pretty solid! Using an array with a single block type and validation to limit it to one line is the standard way to add bold/italic formatting to a title field in Sanity. However, there are a few things you can do to make it feel less like overkill:
According to the block type documentation, you can use the oneLine option to restrict the Portable Text input to a single line:
{
name: 'title',
title: 'Title',
type: 'array',
of: [
{
type: 'block',
styles: [], // Remove style dropdown (no H1, H2, etc)
lists: [], // Remove list options
marks: {
decorators: [
{title: 'Strong', value: 'strong'},
{title: 'Emphasis', value: 'em'}
],
annotations: [] // Remove link option
},
options: {
oneLine: true // This prevents hitting return!
}
}
],
validation: Rule => Rule.required().max(1)
}The key improvements here:
oneLine: true - This disables the ability to hit return and keeps everything on a single linestyles: [] - Removes the style dropdown (Normal, H1-H6, blockquote)lists: [] - Removes bullet/numbered list optionsannotations: [] - Removes the link annotation if you don't need itUnfortunately, there's no built-in option to reduce the WYSIWYG height to match a string field exactly. The Portable Text Editor has a minimum height by default. However, you can use custom components to add custom CSS:
{
type: 'block',
// ... other config
components: {
input: (props) => (
<div style={{ minHeight: 'auto' }}>
{props.renderDefault(props)}
</div>
)
}
}This approach gives you inline formatting in what feels much more like a title field, while still being technically correct as Portable Text.
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