AdaptTable for Base UI

Column groups in Base UI

A parent with children is a column group. This table has three, two children each, open by default. Collapse one to see its mode. Actions stays ungrouped at the end.

Contact is Name + Role with no collapse options: fold is the chevron. Assignment is Team + Status with collapsedKey: "team". Delivery is Timeline + Budget with collapsedRender ($25,300 for 35 days) and align: "start".

collapsibleColumnGroups arms the toggles. The headers and the chevrons are Base UI.

A group header is a centred Base UI ColumnHeaderCell spanning its children, with a Base UI Button chevron; a collapsed stub keeps the name on the control.

The code

import { DataTable, type ColumnInput } from "@adapttable/base-ui";

const columns: ColumnInput<Person>[] = [
  {
    header: "Contact",
    children: [
      { key: "name", header: "Name" },
      { key: "role", header: "Role" },
    ],
  },
  {
    header: "Assignment",
    collapsedKey: "team",
    children: [
      { key: "team", header: "Team" },
      { key: "status", header: "Status" },
    ],
  },
  {
    header: "Delivery",
    align: "start",
    collapsedRender: (row) => row.budget + " for 35 days",
    children: [
      { key: "timeline", header: "Timeline" },
      { key: "budget", header: "Budget" },
    ],
  },
];

export function People({ rows }) {
  return (
    <DataTable
      data={rows}
      columns={columns}
      rowKey={(row) => row.id}
      collapsibleColumnGroups
    />
  );
}

Install

pnpm add @adapttable/base-ui @adapttable/core @base-ui/react

The same feature in the other kits

More Base UI features

Reference: column-groups, columns. More of this kit: AdaptTable for Base UI, or the live demo.