# Markdown Table (/docs/agent-ui/components/markdown-table)

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`.

<Example caption="Press the copy button to copy the table as tab-separated text, ready to paste into a spreadsheet.">
<h />

```tsx
import type { CSSProperties } from "react";
import { MarkdownTable } from "@/components/ui/markdown-table";

const rows = [
  { region: "us-east-1", requests: "18,204,113", errors: "1,204", p99: "380 ms" },
  { region: "eu-west-1", requests: "9,881,402", errors: "312", p99: "295 ms" },
  { region: "ap-south-1", requests: "4,117,950", errors: "2,871", p99: "1.2 s" },
];

export default function MarkdownTableExample() {
  return (
    <MarkdownTable
      aria-label="Latency by region"
      style={{ "--kind-markdown-table-columns": 4 } as CSSProperties}
    >
      <thead>
        <tr>
          <th>Region</th>
          <th data-align="right">Requests</th>
          <th data-align="right">Errors</th>
          <th data-align="right">p99</th>
        </tr>
      </thead>
      <tbody>
        {rows.map((row) => (
          <tr key={row.region}>
            <td>{row.region}</td>
            <td data-align="right">{row.requests}</td>
            <td data-align="right">{row.errors}</td>
            <td data-align="right">{row.p99}</td>
          </tr>
        ))}
      </tbody>
    </MarkdownTable>
  );
}
```
</Example>

## Installation [#installation]

```bash tab="React"
npx shadcn@latest add @kind-ui/markdown-table
```

```bash tab="Web Components"
npx shadcn@latest add @kind-ui/markdown-table-web
```

## Usage [#usage]

### Columns [#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 [#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 [#api-reference]

### MarkdownTableChildren

| Prop        | Type        | Description                      |
| ----------- | ----------- | -------------------------------- |
| `children?` | `ReactNode` | The table's `thead` and `tbody`. |

### Agent [#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:

### MarkdownTableAgentActions

| Prop   | Type                     | Description                                             |
| ------ | ------------------------ | ------------------------------------------------------- |
| `copy` | `() => Promise<boolean>` | Copies the table as tab-separated text, a row per line. |

<Caption>
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.
</Caption>