
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see your issue! The problem is that you're using value in your component props, but for block-level elements like headings and paragraphs, you should be using children instead. The value prop contains the raw block data, while children contains the already-rendered text content.
Here's the corrected code:
const ptComponents = {
block: {
h1: ({ children }) => {
return <h1 className="whiteText">{children}</h1>;
},
p: ({ children }) => {
return <p className="whiteText">{children}</p>;
},
},
};The key difference: children instead of value.
When @portabletext/react processes block-level elements (like paragraphs and headings), it:
children to your custom componentvalue prop contains the raw JSON structure of the block, which isn't what you want to renderIf you need access to the raw block data (for example, to check custom fields), you can use both:
h1: ({ children, value }) => {
console.log(value); // Raw block data
return <h1 className="whiteText">{children}</h1>;
}You can also apply different styles based on the block's properties:
block: {
normal: ({ children }) => <p className="whiteText">{children}</p>,
h1: ({ children }) => <h1 className="whiteText text-4xl">{children}</h1>,
h2: ({ children }) => <h2 className="whiteText text-3xl">{children}</h2>,
}For more complex styling scenarios, check out the ultimate guide for customising Portable Text which covers everything from schema to React components.
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