Docs › Blocks
Tables
Insert tables, add and delete rows and columns, merge cells, header rows, cell colors, column widths.
For price lists, schedules and comparisons. Pick a size from the table button, then put the caret in the table to get its editing bar above it.
Try it
| Plan | Monthly | Storage |
|---|---|---|
| Basic | Free | 1 GB |
| Pro | $9 | 100 GB |
| Cancel any plan at any time. | ||
Code for this demo
createEditor('#editor', {
toolbar: 'heading | bold color | table | undo redo',
});Inserting a table
- The
tablebutton opens a 10 × 10 grid. Hover to choose the size and click. From the keyboard, use the arrow keys and Enter. - On an empty line, type
/and pick "Table" for a 3 × 3 table (Slash menu). - Tables copied from Excel, HWP or Word keep their structure, merged cells included (Paste cleanup).
The table bar
With the caret in a table, a bar shows above it. From the left:
| Button | What it does |
|---|---|
| Insert row above / below | Adds an empty row. A merged cell that spans across it grows by one. |
| Insert column left / right | Adds an empty column next to the caret. |
| Delete row / Delete column | Deletes the rows or columns of the caret (or of the selected cells). Deleting all of them removes the table. |
| Merge cells | Merges two or more selected cells. Their text is joined with line breaks. |
| Split cell | Splits a merged cell back into its cells. The text stays in the first one. |
| Header row | Turns the first row into <th scope="col"> header cells (gray, bold), or back. |
| Cell color | Background of the selected cells (or the caret cell). Includes none, custom and recent colors. |
| Borders | 1px, 2px, 3px or none, for the selected cells or the whole table. Cells without borders show a dashed guide only while editing. |
| Vertical align | Top, middle or bottom. |
| Delete table | Removes the table and leaves an empty paragraph. |
Selecting and moving
- Drag from one cell to another to select a rectangle of cells. Merged cells widen the rectangle as needed.
- Tab moves to the next cell, Shift+Tab to the previous one. Tab in the last cell adds a row.
- Point at the right edge of a cell and drag to resize the column (30px minimum). On the first drag every column is fixed at its current width, so only the dragged one changes.
Saved HTML
The look is stored as inline styles, so the table looks the same on a page without any extra CSS.
<div data-table-wrap="" style="overflow-x: auto">
<table style="border-collapse: collapse; width: 100%"><tbody>
<tr><th style="border: 1px solid #d0d5dd; …; background-color: #f2f4f7; font-weight: 600" scope="col">Plan</th>…</tr>
<tr><td style="border: 1px solid #d0d5dd; padding: 6px 8px; vertical-align: top">Basic</td>…</tr>
</tbody></table>
</div>The outer div[data-table-wrap] comes from responsiveOutput (on by default): on narrow phone screens the table scrolls sideways instead of overflowing the page. It is taken off again when the HTML is loaded back into the editor.
From code
Every button on the table bar is an editor.exec() command, so your own buttons and shortcuts can do the same.
editor.exec('insertTable', '4x3'); // 4 rows, 3 columns
editor.exec('rowBelow'); // rowAbove, colLeft, colRight
editor.exec('deleteRow'); // deleteCol, deleteTable
editor.exec('mergeCells'); // splitCell
editor.exec('headerRow');
editor.exec('cellColor', '#fff3bf'); // '' removes the color
editor.exec('cellVAlign', 'middle'); // top | middle | bottom
editor.exec('tableBorder', '0'); // 0 | 1 | 2 | 3 (px)Presets and phones
The table button is on the first row of the basic, board (default) and full presets, not in minimal. On phones the default board toolbar keeps one row of essentials, so the table button moves under ⋯.
Options
| Name | Type | Default | Description |
|---|---|---|---|
table | toolbar item | - | Insert a table (10 × 10 size grid) |
colors | string[] | 20 cell colors | When set, both the text color palette and the cell color palette use this list. Unset, cells get their own palette of mostly light colors. |
responsiveOutput | boolean | true | Wrap saved tables in a sideways-scrolling box. false saves the bare table. |