Docs
Table

Table

Organize and display data in a structured and resizable tabular format.

🏓 Table

Create customizable tables with resizable columns and rows, allowing you to design structured layouts.
Plugin
Element
Inline
Void
Heading
Yes
No
No
Image
Yes
No
Yes
Mention
Yes
Yes
Yes
This table is an example of rendering a table spanning multiple columns:
Heading
Cell 1
Cell 2


Features

  • Enables creation and editing of tables with advanced behaviors.
  • Arrow navigation (up/down).
  • Grid cell selection.
  • Cell selection expansion with Shift+Arrow keys.
  • Copying and pasting cells.

Installation

npm install @udecode/plate-table

Usage

// ...
import { createTablePlugin } from '@udecode/plate-table';
 
const plugins = [
  // ...otherPlugins,
  createTablePlugin({
    options: {
      initialTableWidth: 600,
    },
  }),
];

API

createTablePlugin

Attributes

Collapse all

    Options.

    Disables the expansion of the table when inserting cells.

    Disables the left resizer of the first column in the table.

    Disables unsetting the width of the first column when the table has only one column. Set this to true if you want to resize the table width when there's only one column. Leave it false if you have a full-width table.

    Defines the content of a newly inserted cell.

    • Default: an empty paragraph

    The function to insert a new column into the table.

    • Default: insertTableColumn

    The function to insert a new row into the table.

    • Default: insertTableRow

    If defined, a normalizer will set each undefined table colSizes to this value divided by the number of columns. Note that merged cells are not yet supported.

    The minimum width of a column in the table.

    • Default: 48

deleteColumn

deleteRow

deleteTable

getCellInNextTableRow

getCellInPreviousTableRow

getCellType

getEmptyCellNode

getEmptyRowNode

getEmptyTableNode

getLeftTableCell

getNextTableCell

getPreviousTableCell

getTableAbove

getTableColumnCount

getTableColumnIndex

getTableEntries

getTableGridAbove

getTableGridByRange

getTableOverriddenColSizes

getTableRowIndex

getTopTableCell

insertTable

insertTableColumn

insertTableRow

isTableBorderHidden

moveSelectionFromCell

overrideSelectionFromCell

setBorderSize

setTableColSize

setTableMarginLeft

setTableRowSize

API Plugin

onKeyDownTable

withDeleteTable

withGetFragmentTable

withInsertFragmentTable

withInsertTextTable

withNormalizeTable

withSelectionTable

withSetFragmentDataTable

withTable

API Components

TableCellElementResizable

getOnSelectTableBorderFactory

getTableCellBorders

roundCellSizeToStep

tableStore

useIsCellSelected

useSelectedCells

useTableBordersDropdownMenuContentState

useTableCellElementState

useTableColSizes

useTableElement

Keyboard Interactions

KeyDescription
Shift + ArrowUpAdd the cell above to selection.
Shift + ArrowDownAdd the cell below to selection.
Shift + ArrowLeft

Add the left cell to selection.

Shift + ArrowRight

Add the right cell to selection.

Shift + TabSelect the previous cell.
TabSelect the next cell.
Cmd + ASelect all the table cells.