Markdown Table
Show a table that scrolls sideways instead of squeezing its columns, with a copy button.
Use a markdown table for tabular data in a reply. Markdown renders its tables in one, and you can use it on its own: put a thead and a tbody inside, and name it with aria-label.
| Region | Requests | Errors | p99 |
|---|---|---|---|
| us-east-1 | 18,204,113 | 1,204 | 380 ms |
| eu-west-1 | 9,881,402 | 312 | 295 ms |
| ap-south-1 | 4,117,950 | 2,871 | 1.2 s |
Installation
npx shadcn@latest add @kind-ui/markdown-tableUsage
Columns
Set --kind-markdown-table-columns to the number of columns. Each column then keeps at least --kind-markdown-table-column-width (8rem by default), and a wider table scrolls sideways. Columns hold their width as rows stream in, so the table doesn't reflow. Set data-align to right or center on a cell to align it.
Copying
The copy button copies the table as tab-separated text, a row per line, and turns into a check for two seconds. Tab reaches it, and Enter or Space presses it. It tells screen readers "Copied", or "Copy failed" when the browser refuses the clipboard write.
API Reference
Prop
Type
Agent
An agent connected with createAgent sees the table by its name. It can run this action, and press the copy button like a person would:
Prop
Type
Runs in React and Web Components. On <kind-markdown-table>, write a table inside the element, and it moves into place beside the copy button.