Skip to main content

MessageTable

Conversationai

A model-emitted, column-oriented data table rendered as message content.

import { MessageTable } from "@elabs-ai/components-ai";
Install
npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-ai

Skipping the @source line is the most common first failure: Tailwind does not scan node_modules, so every component renders unstyled. The one-time wiring

Prompt for your coding agent

Paste it into Claude Code, Cursor, Codex or any other coding agent. Text in [brackets] is yours to fill in.

Add the brand-ui MessageTable component (from @elabs-ai/components-ai) to this project.

1. Read https://elabs-ai.com/llms.txt first: it maps every package and the rules. If you can use MCP servers, connect https://elabs-ai.com/mcp and use its search, docs and tokens tools. If not, run the same lookups in the terminal: `npx -y @elabs-ai/components-cli search "<what you need>"` and `npx -y @elabs-ai/components-cli docs <Component>`.
2. Look MessageTable up before writing code: `npx -y @elabs-ai/components-cli docs MessageTable` prints its real props, variants, what it pairs with and what to avoid.
3. If @elabs-ai/components-ai is not installed yet: `pnpm add @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-ai` (or `npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-ai`). If this is the first brand-ui package in the project, wire it once: import `@elabs-ai/components-tokens/styles.css` plus the `themes/light.css` and `themes/dark.css` stylesheets in the CSS entry, add one Tailwind `@source` line per installed @elabs-ai package (Tailwind does not scan node_modules, so without it everything renders unstyled), and wrap the app root in `ThemeProvider` from `@elabs-ai/components-tokens`.
4. Use it here: [the screen or file, and what it should show]
5. Rules: use only @elabs-ai/components-* components and the semantic tokens — no raw colours, no raw font sizes, no arbitrary Tailwind values. Look up each component's real props with the docs tool before you use it; never guess a prop.
6. Done means: the typecheck passes, `npx -y @elabs-ai/components-cli audit src --strict` reports nothing, and you have opened the app and looked at every screen you touched in the light and the dark theme.

Avoid

  • Reaching for the DataTable instead — that is app chrome; this is message content, deliberately lighter.
  • Throwing on a malformed spec — it falls back (MessageTableFallback), renders an em-dash for a missing cell, and drops half-arrived rows.
  • Start-aligning numeric columns — numerics are end-aligned with tabular-nums so they compare down the column.

Works with

Used inside

  • Message

Avoid next to

Examples

11 live examples

Sortable

Sortable — click a header to sort; numeric columns sort numerically.

Controlled Sort

Controlled sort — the parent owns the sort state.

Truncated

Truncated — `maxRows` caps the display and shows a "Showing N of M" notice.

Streaming Rows

Streaming / partial — columns known, rows still arriving → skeleton rows.

Partial Rows

Missing cells render an em-dash — a half-arrived row never crashes.

Empty

Empty (not streaming) — a real empty state row, never broken UI.

Fallback

Fallback — a non-object spec renders a typed fallback (no throw).

Custom Cell

Per-cell override — compose custom cell content (like ChangeReview.renderHunk).

Dark Theme

Dark theme — verifies token-driven surfaces + dividers in dark.

Focus Indicator

Focus indicator on sortable column headers (#313): Tab to a sort header and assert the compound indicator's OUTLINE layer (`outlineStyle: "solid"`, `--ring-contour`) that `focus-ring` adds. `boxShadow !== "none"` alone also passes on the legacy `focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1` pattern (Tailwind's `ring-2` still paints a box-shadow), so it does not lock the fix.

API

MessageTable

PropTypeDescription
specrequiredTableSpec | unknownThe serializable table specification produced by an LLM tool-call.
sortablebooleanEnable click-to-sort column headers. @default false
sortTableSort | nullControlled sort. When provided, `onSortChange` is the only way to update it.
defaultSortTableSort | nullUncontrolled initial sort.
onSortChange(sort: TableSort | null) => voidCalled with the next sort (or `null`) when a header is clicked.
maxRowsnumberCap the number of rendered rows; shows a "Showing N of M rows" notice.
renderCellRenderCellPer-cell render override for custom composition.
isStreamingbooleanThe spec is still streaming (columns-but-no-rows shows skeleton rows).
streamingboolean@deprecated Use `isStreaming`.

Also accepts: Omit<HTMLAttributes<HTMLDivElement>, "title">

MessageTableFallback

PropTypeDescription
messagestringShort human reason the table could not render.

Also accepts: HTMLAttributes<HTMLDivElement>