gridland
Components

Table

A data table with automatic column sizing and compound sub-components

A data table with automatic column detection, horizontal-only separators, and a compound sub-component API for full layout control.

Table
?

Run demo

Terminal
bunx @gridland/demo table
Terminal
curl -fsSL https://raw.githubusercontent.com/thoughtfulllc/gridland/main/scripts/run-demo.sh | bash -s table

Installation

bunx shadcn@latest add @gridland/table

Usage

import { Table } from "@/components/ui/table"
<Table
  data={[
    { name: "Alice", role: "Engineer", status: "Active" },
    { name: "Bob", role: "Designer", status: "Active" },
    { name: "Charlie", role: "PM", status: "Away" },
  ]}
/>

Examples

Custom Columns

Select and order which columns to display.

Custom columns
<Table
  data={[
    { name: "Alice", age: 30, role: "Engineer" },
    { name: "Bob", age: 25, role: "Designer" },
  ]}
  columns={["name", "role"]}
/>

Custom Colors

Override the default header and separator colors.

Custom colors
<Table
  data={[
    { name: "Alice", role: "Engineer" },
    { name: "Bob", role: "Designer" },
  ]}
  headerColor="cyan"
  borderColor="#5e81ac"
/>

Compound API

For full layout control, use TableRoot with sub-components.

Compound table
import {
  TableRoot,
  TableHeader,
  TableBody,
  TableFooter,
  TableRow,
  TableHead,
  TableCell,
  TableCaption,
} from "@/components/ui/table"

<TableRoot>
  <TableCaption>A list of your recent invoices.</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead>Status</TableHead>
      <TableHead>Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>INV001</TableCell>
      <TableCell>Paid</TableCell>
      <TableCell>$250.00</TableCell>
    </TableRow>
  </TableBody>
  <TableFooter>
    <TableRow>
      <TableCell>Total</TableCell>
      <TableCell></TableCell>
      <TableCell>$250.00</TableCell>
    </TableRow>
  </TableFooter>
</TableRoot>

Compound Components

ComponentDescription
TableRootCompound root — computes column widths and provides layout context
TableHeaderWraps header rows with a solid separator below
TableBodyWraps body rows with dimmed separators between them
TableFooterWraps footer rows with a solid separator above
TableRowReads TableHead/TableCell children and renders a styled row
TableHeadHeader cell — does not render on its own
TableCellBody cell — does not render on its own
TableCaptionMuted caption text below the table

API Reference

Table

Data-driven table with automatic column detection.

PropTypeDefaultDescription
dataT[]-Array of data objects to display
columns(keyof T)[]-Keys to display as columns (auto-detected if omitted)
paddingnumber1Cell padding in characters
headerColorstringtheme.foregroundHeader text color
borderColorstringtheme.mutedSeparator line color

TableRoot

Compound root that computes column widths from the component tree.

PropTypeDefaultDescription
childrenReactNode-Table sub-components
paddingnumber1Cell padding in characters
headerColorstringtheme.foregroundHeader text color
borderColorstringtheme.mutedSeparator line color

TableHeader

PropTypeDescription
childrenReactNodeOne or more TableRow components

TableBody

PropTypeDescription
childrenReactNodeOne or more TableRow components

TableFooter

PropTypeDescription
childrenReactNodeOne or more TableRow components

TableRow

PropTypeDescription
childrenReactNodeTableHead or TableCell components

TableHead

PropTypeDescription
childrenReactNodeCell content (typically a string)

TableCell

PropTypeDescription
childrenReactNodeCell content (typically a string)

TableCaption

PropTypeDescription
childrenReactNodeCaption text