Skip to main content
Tables in the Decks SDK give you the full spreadsheet-style layout experience: column definitions with per-column alignment and width, cells that accept plain values or rich styled objects with span merging, and a styles block that controls header appearance, body cells, alternating row colors, and border presets. The table() builder validates every input through Zod and produces a canonical table document ready for placement. You can author a table with the table() builder function or with the inline { type: 'table', columns, rows, ... } object syntax. The builder supports the full option set including styles and showGridLines; the inline syntax supports columns, rows, and headerRows.

Basic example


Columns

Columns define the table’s structure. Each column can be a plain string header label, or a rich object for alignment, width, and per-column styling.

Simple string columns

When you pass a string, the SDK uses it as the header label and auto-generates a stable key from it (lowercased, spaces replaced with underscores).

Rich column objects

Use a rich column object when you need to control alignment, width, or per-column cell styling.
string
required
The column header label displayed in the first row.
string
Stable column key used internally to map row cell values. Auto-generated from header when omitted. Set this explicitly when you need predictable keys for later chart operations or incremental updates.
'left' | 'center' | 'right'
Horizontal text alignment for all cells in this column, including the header. Can be overridden per cell.
'top' | 'middle' | 'bottom'
Vertical cell alignment for all cells in this column.
number
Fixed column width in pixels. When omitted, columns share available width equally.
CellStyle
Per-column style applied to all body cells in this column (not the header). See CellStyle below.

Rows

Rows are arrays of arrays. Each inner array holds the cell values for one row, positionally matching the columns definition. Cell values can be strings, numbers, null, or rich cell objects.

Simple cell values

Strings and numbers are the most common cell types. Numbers are converted to strings automatically.
Use null for an empty cell:

Rich cell objects

When you need per-cell styling, span merging, or custom alignment, use a rich cell object.
string
Cell text content as a plain string.
object
Advanced: a pre-built rich text document for content with inline formatting (bold, italic, inline code, etc.). Use text for plain strings.
'left' | 'center' | 'right'
Horizontal alignment override for this cell, overriding the column’s default.
'top' | 'middle' | 'bottom'
Vertical alignment override for this cell.
string
Background color override for this cell as a CSS color string.
number
Number of columns this cell spans. Must be a positive integer.
number
Number of rows this cell spans. Must be a positive integer.

Table styles

The styles object controls the visual appearance of the entire table. Pass it as the styles key on your table input.
CellStyle
Style applied to all header row cells. See CellStyle fields.
CellStyle
Default style applied to all body cells (overridden by column styles and per-cell styles).
{ even: CellStyle, odd: CellStyle }
Alternating row background colors. even applies to rows at index 0, 2, 4… and odd to rows at index 1, 3, 5… (zero-indexed, excluding the header).
'none' | 'horizontal' | 'vertical' | 'all' | 'outer'
Border preset for the table:
  • 'none' — no borders
  • 'horizontal' — lines between rows only
  • 'vertical' — lines between columns only
  • 'all' — full grid of borders
  • 'outer' — border around the table perimeter only
string
CSS color for borders drawn by the borders preset.
number
Border thickness in pixels. Defaults to 1.
number
Corner radius in pixels for the outer table border.

CellStyle fields

CellStyle applies to header cells, body cells, column defaults, and alternating row entries.
string
Cell background color as a CSS color string.
'left' | 'center' | 'right'
Horizontal text alignment.
'top' | 'middle' | 'bottom'
Vertical text alignment within the cell.
string
Text color.
string
Font family for cell text.
string
Font size as a CSS string, e.g. '14px'.
string | number
Font weight, e.g. 600 or 'bold'.
string
Per-cell border color override.
string
Cell padding as a CSS shorthand, e.g. '8px 16px'.

Other options

number
Number of rows to treat as header rows. Defaults to 1. Set to 0 to suppress header styling, or 2 for a two-row header with merged spans above.
boolean
When true, renders subtle grid lines between all cells. Independent of the borders style preset.

Complete styled example

Inline syntax equivalent

The same table using the inline layer object:
Keep the key field explicit on columns when you plan to apply incremental updates to a table later. The SDK derives keys from header labels when omitted, which means renaming a column header would break any references keyed by the old derived value.