
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe @sanity/table plugin doesn't have built-in support for designated table headers with <thead> and <th> elements. By default, it stores table data as rows and cells without distinguishing headers from regular content.
The common approach is to treat the first row as headers when rendering the table on your frontend. This is exactly what you'd need to handle yourself.
Here's how you can render the table with proper <thead> and <th> support for accessibility when using the @sanity/table plugin with @portabletext/react:
function BlockTable(props) {
const [head, ...rows] = props.value.rows
const isBiDirectional = head.cells[0].length === 0
return (
<table>
<thead>
<tr>
{head.cells.map(cell => (
<th key={cell}>{cell}</th>
))}
</tr>
</thead>
<tbody>
{rows.map((row, index) => (
<tr key={index}>
{row.cells.map((cell, index) => {
const Component = isBiDirectional && index === 0 ? 'th' : 'td'
return <Component key={index}>{cell}</Component>
})}
</tr>
))}
</tbody>
</table>
)
}Then add this to your PortableText components:
const components = {
types: {
table: BlockTable,
// other types...
},
}
<PortableText components={components} value={_rawField} />This approach:
<thead> with <th> elements)As noted in this community discussion, proper header support is important for accessibility, so make sure you're using <th> elements rather than just <td> for all cells.
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