Back to components
ElementData DisplayFree

Tree Table React component

A table whose rows nest, like files in folders: open and close branches with a chevron, parents add up their children (folder sizes), sort any column with folders kept on top, and tick rows with checkboxes that select whole branches.

About the Tree Table component

Tree Table shows hierarchical data with columns, like a file browser: folders open and close with a chevron to show their children, indented with guide lines, and opened rows slide in under their parent. Parents can show the total of their children in a column, such as folder sizes, and rows can be ticked, with a ticked folder selecting everything inside it.

data takes rows with id, name, values for the extra columns and children. columns sets each column's key, label, alignment, width, an optional sum that totals a parent's children and a format function for the cell. Clicking a column header sorts within each level, with folders kept above files. defaultExpanded opens rows at the start, Expand all and Collapse all buttons sit in the toolbar, and selectable with defaultSelected and onSelectionChange handle the tick boxes.

When to use it

Use Tree Table for data that is both hierarchical and has columns: file browsers, budgets by department, nested categories with counts, bills of materials. Parents can total their children, so people see sums at every level.

For hierarchy without columns, Tree View is lighter; for flat data, use a regular Data Table.

Installation

Add the Tree Table component to your project with the shadcn CLI. It lands in components/tree-table.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/tree-table

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

More Data Display components

Chat Bubble
Free
Transfer List
Free
List Group
Free
Organization Chart
Free
Basic Table
Free
Sortable List
Free