AdaptTable for Radix

Column groups in Radix

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

A group header is a centred Radix ColumnHeaderCell spanning its children, with the kit Button around the chevron; a collapsed stub keeps the name on the accessible label.

The code

import { DataTable, type ColumnInput } from "@adapttable/radix";

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/radix @adapttable/core @radix-ui/themes

The same feature in the other kits

More Radix features

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