Table

A table with rich text (Slate) content in each cell. Supports adding/removing rows and columns via toolbar actions.

The table example block being edited in Volto Hydra

Basic Table

Title Tablehead

Title Tablehead

Title Tablehead

Title Tablehead

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Stripe alternating rows with colors

Title Tablehead

Title Tablehead

Title Tablehead

Title Tablehead

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Basic Table

Title Tablehead

Title Tablehead

Title Tablehead

Title Tablehead

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Stripe alternating rows with colors

Title Tablehead

Title Tablehead

Title Tablehead

Title Tablehead

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link

Heading H2Heading H3Text can be bold or italic or a Link


Developer Reference

Schema

Pass this object inside the blocks option when calling initBridge() to register this block type with the admin UI. See Custom Blocks for the full setup guide.

{
  "slateTable": {
    "addMode": "table",
    "blockSchema": {
      "properties": {
        "table": {
          "title": "Table",
          "widget": "object",
          "schema": {
            "properties": {
              "rows": {
                "widget": "object_list",
                "idField": "key",
                "addMode": "table",
                "schema": {
                  "properties": {
                    "cells": {
                      "widget": "object_list",
                      "idField": "key",
                      "schema": {
                        "properties": {
                          "value": {
                            "widget": "slate"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

JSON Block Data

Example JSON as stored in the Plone content API. This is the data structure your component will receive in the block prop.

{
  "@type": "slateTable",
  "table": {
    "rows": [
      {
        "key": "row-1",
        "cells": [
          {
            "key": "cell-1",
            "value": [
              {
                "type": "p",
                "children": [
                  {
                    "text": "Name"
                  }
                ]
              }
            ]
          },
          {
            "key": "cell-2",
            "value": [
              {
                "type": "p",
                "children": [
                  {
                    "text": "Role"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "key": "row-2",
        "cells": [
          {
            "key": "cell-3",
            "value": [
              {
                "type": "p",
                "children": [
                  {
                    "text": "Alice"
                  }
                ]
              }
            ]
          },
          {
            "key": "cell-4",
            "value": [
              {
                "type": "p",
                "children": [
                  {
                    "text": "Engineer"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

Rendering

How this block renders in your frontend. Add its handling to your renderer, or — for list-style blocks — register a fetcher and reuse your list rendering.

function TableBlock({ block }) {
  const rows = block.table?.rows || [];
  return (
    <div data-block-uid={block['@uid']}>
      <table>
        <tbody>
          {rows.map(row => (
            <tr key={row.key} data-block-uid={row.key}>
              {row.cells.map(cell => (
                <td key={cell.key} data-block-uid={cell.key} data-edit-text="value">
                  {(cell.value || []).map((node, i) => (
                    <SlateNode key={i} node={node} />
                  ))}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}