Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Data table block

A sortable, paginated grid of rows and columns, for datasets larger than the plain table block handles.

data_table renders a grid with a header row, per-column sorting, and pagination once a table has more than a handful of rows. It isn’t part of the public @slack/types package, so treat this page’s field list as the reference.

Your AppAPP
Open deals
Acme Expansion Deal
Acme Inc.
Negotiation
Weather Forecast Integration
Nimbus Corp.
Waiting on review
Retail Partner Portal
ShopCo Ltd.
Closed Won

Fields

PropType
typestring

Always data_table.

Typestring
caption?string

Shown above the table and used to label the expand control.

Typestring
rowsCell[][]

The grid, header row first. rows[0] is the header and sets the column count (rows[0].length); every subsequent row is a data row.

TypeCell[][]

Cell

Each cell is one of four shapes, picked by type:

PropType
raw_text?{ type: "raw_text", text: string }

Plain text, sorted alphabetically.

Type{ type: "raw_text", text: string }
raw_number?{ type: "raw_number", value: number, text: string }

A number with its own display text. Sorts numerically by value, displays text.

Type{ type: "raw_number", value: number, text: string }
url?{ type: "url", url: string, text?: string }

A link, opened in a new tab. text defaults to the raw URL. The URL goes through the same check as every payload link (URL safety): a javascript: or other unsafe URL shows its text with no link.

Type{ type: "url", url: string, text?: string }
rich_text?RichTextBlock

A Slack rich text node: bold, italic, and other inline styles, links, and user mentions (named by resolvers.user, else a loading pill, or the outline of a missing user when resolvers.user doesn't know them, with Slack's "Private user info" tooltip).

TypeRichTextBlock

With only a header row, the table shows the header and no data rows. With an empty rows, it shows the caption and toolbar and no columns.

Every control is a button, so the keyboard works as it does for any button: Tab moves between the toolbar, the column headers, a cell’s Expand cell button and the page controls, and Enter or Space activates the focused one. A header activated this way cycles its sort like a click.

The toolbar’s More actions button opens Slack’s menu with Copy table, which copies the whole table as tab-separated text that pastes into a spreadsheet, and Download table, which saves it as table.csv. Both take every row, header first, in the payload’s order, whatever the sort or page. In both, a cell a spreadsheet would read as a formula gets a leading ', as in the table block. The toolbar’s view button is drawn but doesn’t do anything yet.

The toolbar’s Search table button turns into a Filter table… box, as in Slack. As you type, the table keeps only the rows with a cell that contains the term, ignoring case. Rich text cells count too. The first occurrence of the term in each matching cell is highlighted. A filtered table keeps the height of its first page. When no row matches, it shows No results found. and a Clear filter button. Clear in the box empties it. Escape clears the term, closes the box and puts focus back on the Search button. An empty box closes when focus leaves it, while a box with a term stays open. Filtering starts again from page 1, and sorting applies to the rows left.

A cell shows one line, cut off with an ellipsis. When its content doesn’t fit, hovering the cell shows an Expand cell button, as in Slack. The button also shows on keyboard focus. It opens the whole content in a Cell content dialog laid over the cell, as wide as it and scrolling past 144px. Escape or a click outside closes it. Like the menus, it acts in the page only and never calls onAction.

Examples

Basic table

The preview above is fixtures/catalog/table/basic-data-table.json, a mix of raw_text and rich_text cells.

Numeric sorting

Your AppAPP
Acme Inc.
$42,000
Nimbus Corp.
$8,500
ShopCo Ltd.
$120,000

raw_number cells sort by their numeric value, not by the formatted text, so $8,500 sorts below $42,000 even though "$120,000" would sort first alphabetically.

Pagination

Add more than 5 data rows and page controls appear automatically:

{ "blocks": [ { "type": "data_table", "caption": "All accounts", "rows": [ [ { "type": "raw_text", "text": "Name" }, { "type": "raw_text", "text": "Owner" }, { "type": "raw_text", "text": "Status" } ], [ { "type": "raw_text", "text": "Acme Inc." }, { "type": "raw_text", "text": "Ada Lovelace" }, { "type": "raw_text", "text": "Active" } ], [ { "type": "raw_text", "text": "Nimbus Corp." }, { "type": "raw_text", "text": "Grace Hopper" }, { "type": "raw_text", "text": "Active" } ], [ { "type": "raw_text", "text": "ShopCo Ltd." }, { "type": "raw_text", "text": "Alan Turing" }, { "type": "raw_text", "text": "Active" } ], [ { "type": "raw_text", "text": "GreenTech" }, { "type": "raw_text", "text": "Ada Lovelace" }, { "type": "raw_text", "text": "Churned" } ], [ { "type": "raw_text", "text": "LogiFlow Inc." }, { "type": "raw_text", "text": "Grace Hopper" }, { "type": "raw_text", "text": "Active" } ], [ { "type": "raw_text", "text": "Northwind Traders" }, { "type": "raw_text", "text": "Alan Turing" }, { "type": "raw_text", "text": "Active" } ] ] } ] }

Last updated on