
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes! There's absolutely a way to reduce the size of a Portable Text editor field. While there isn't a built-in rows option like there is for regular text fields, you can control the editor height using a custom input component.
The approach involves creating a custom input component that wraps the default Portable Text editor and applies custom styling to reduce its height. Here's how to do it:
You'll need to create a custom input component that:
styled-components (or your preferred CSS solution) to control the editor heightrenderDefault outputinitialActive: true so users can start typing immediately without clicking to activateHere's a complete example from Sanity's documentation on reducing PTE height:
// CharacterCountInputPTE.tsx
import { Stack, Text } from '@sanity/ui'
import { PortableTextInputProps } from 'sanity'
import styled from 'styled-components'
export function CustomPTEInput(props: PortableTextInputProps) {
return (
<Container>
{props.renderDefault({
...props,
initialActive: true, // Removes need to activate the editor
})}
</Container>
)
}
// Target the editor when not in fullscreen mode
const Container = styled.div`
[data-testid='pt-editor'][data-fullscreen='false'] {
height: 100px; /* Adjust to your needs */
}
`Then reference this custom component in your schema field definition:
import { CustomPTEInput } from './path-to-your-component'
defineField({
name: 'intro',
type: 'array',
title: 'Introduction',
components: {
input: CustomPTEInput,
},
of: [
defineArrayMember({
type: 'block',
// ... your block configuration
}),
],
})intro can be visually distinguished from larger fields like bodyinitialActive: true removes the extra click to start editingYou can enhance this further by adding a character counter based on validation rules, which is particularly useful for meta descriptions or other length-constrained fields. The full guide shows how to extract the max value from your field validation and display it alongside a live character count.
This is a great example of how custom input components give you precise control over the editing experience in Sanity Studio!
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