
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeLooking at your code, I can see the issue! In Portable Text, span isn't actually a type you can customize in the types object. Spans are the text content within blocks, and they're handled differently.
Here's what's happening in your Portable Text structure:
types.blockmarksTo customize how text renders, you need to target the block type. Your block handler is on the right track, but you need to return something for the default "normal" style too:
const serializer = {
types: {
figure: ({ value }) => <Image data={value} />,
block(props) {
switch (props.node.style) {
case "h1":
return <Text fontSize="8em">{props.children}</Text>;
case "h2":
return <Text fontSize="6em">{props.children}</Text>;
case "normal": // This is the default paragraph style
return <Text fontSize="2em">{props.children}</Text>;
default:
return <Text>{props.children}</Text>;
}
},
},
};The key things to fix:
span from types - it's not a valid type to override thereprops.children in your block handler - this renders the actual text content"normal" style - plain paragraphs have style: "normal", not "span"If you want to customize individual text spans (like making specific words different), you'd use the marks object instead. For example, if you had a custom annotation or wanted to override how bold text renders:
const serializer = {
types: { /* your block handlers */ },
marks: {
strong: ({ children }) => <Text fontWeight="bold">{children}</Text>,
// custom marks would go here too
},
};The ultimate guide for customizing Portable Text has great examples of all the different ways you can customize rendering, including blocks, marks, and annotations!
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