Introducing PrimeReact v11-alpha 🎉Discover Now
styledData

TreeTable

TreeTable renders hierarchical data with the same feature set as DataTable — sort, filter, pagination, selection, scroll, frozen, resize, reorder, editing, export.

NameSizeType
Documents
75kbFolder

Usage#

import { DataTable } from '@primereact/ui/datatable';

TreeTable is DataTable with the treeMode prop set on DataTable.Root. Every feature shown in DataTable continues to work over the flattened tree — the only structural difference is that the first column wraps its cell content with DataTable.RowToggle to render the expand/collapse chevron.

<DataTable.Root data={treeNodes} dataKey="key" treeMode expandedKeys={expandedKeys} onExpandedChange={(e) => setExpandedKeys(e.value)}>
    <DataTable.TableContainer>
        <DataTable.Table>
            <DataTable.THead>
                <DataTable.THeadRow>
                    <DataTable.THeadCell>Name</DataTable.THeadCell>
                </DataTable.THeadRow>
            </DataTable.THead>
            <DataTable.TBody>
                {({ item }) => (
                    <DataTable.Row>
                        <DataTable.Cell>
                            <DataTable.RowToggle />
                            {item.name}
                        </DataTable.Cell>
                    </DataTable.Row>
                )}
            </DataTable.TBody>
        </DataTable.Table>
    </DataTable.TableContainer>
</DataTable.Root>

Data shape#

Each node carries its own key, arbitrary data, and an optional children array:

type TreeNode = {
    key: string;
    data: Record<string, unknown>;
    children?: TreeNode[];
};

Set dataKey="key" and resolve column values against item.<field> — the component flattens data onto the row so columns can read directly.

Rows are augmented with derived fields the component consumes internally: _treeLevel, _treeHasChildren, _treePosInSet, _treeSetSize. These drive the ARIA attributes (aria-level, aria-expanded, aria-posinset, aria-setsize) automatically.

Examples#

Basic#

Displays hierarchical nodes with expand/collapse chevrons on the first column.

NameSizeType
Documents
75kbFolder
basic-demo

Size#

Use the size prop with small or large to adjust cell padding.

NameSizeType
Documents
75kbFolder
size-demo

Gridlines#

Enable the showGridlines prop to render borders between cells.

NameSizeType
Documents
75kbFolder
gridlines-demo

Striped Rows#

The stripedRows prop renders rows with alternating background colors across the flattened tree.

NameSizeType
Documents
75kbFolder
Pictures
150kbFolder
barcelona.jpg
90kbPicture
primeui.png
30kbPicture
optimus.jpg
30kbPicture
striped-rows-demo

Selection#

Selection works exactly like DataTable — selectionMode controls the mode, and the DataTable.Selection render prop exposes helpers for row-level and header-level toggles. Checkbox selection propagates across the hierarchy with tri-state semantics.

Single#

NameSizeType
single-selection-demo

Multiple#

Pair selectionMode="multiple" with metaKeySelection so Ctrl/Cmd + Click toggles rows and Shift + Click selects a range.

NameSizeType
multiple-selection-demo

Checkbox#

Checkbox column with propagating selection — toggling a parent selects all descendants, partial state renders as indeterminate.

Selected: None
Name
SizeType
Documents
75kbFolder
Work
55kbFolder
Expenses.doc
30kbDocument
Resume.doc
25kbDocument
checkbox-selection-demo

Radio#

NameSizeType
radio-selection-demo

Keyboard#

Arrow Up/Down moves focus between rows, Arrow Right/Left expands/collapses, Space or Enter toggles the focused row, and Shift + Arrow extends a range.

navigate, expand, collapse, Space select
Selected
NameSizeType
keyboard-demo

Sort#

Sorting is evaluated per tree level — siblings are sorted against each other while the hierarchy stays intact.

Single#

sort-demo

Multiple#

multisort-demo

Presort#

presort-demo
presort-multi-demo

Pagination#

Pagination operates on root-level nodes — expanded children never get paginated away.

NameSizeType
pagination-demo

Scroll#

scrollable + scrollHeight works the same way as in DataTable; the flattened rows scroll while the sticky header stays pinned.

Vertical#

NameSizeType
Folder 1
Folder
Document 1.1
50kbDocument
Text 1.2
163kbText
Picture 1.3
276kbPicture
Video 1.4
389kbVideo
Document 1.5
502kbDocument
Text 1.6
615kbText
Folder 2
Folder
Document 2.1
87kbDocument
Text 2.2
200kbText
Picture 2.3
313kbPicture
Video 2.4
426kbVideo
Document 2.5
539kbDocument
Text 2.6
652kbText
scroll-vertical-demo

Horizontal#

NameSizeTypeKeyLevelHas Children
scroll-horizontal-demo

Flex#

NameSizeType
scroll-flex-demo

Frozen Columns#

Pin the tree column (or any column) during horizontal scroll with the frozen prop on DataTable.Column.

NameSizeTypeOwnerModifiedActions
Folder 1
FolderAmy Elsner2026-01-15Open · Share
Document 1.1
50kbDocumentAmy Elsner2026-01-20Open · Share
Text 1.2
163kbTextAnna Fali2026-02-20Open · Share
Picture 1.3
276kbPictureBernardo Dominic2026-03-20Open · Share
Video 1.4
389kbVideoIoni Bowcher2026-04-20Open · Share
Document 1.5
502kbDocumentStephen Shaw2026-05-20Open · Share
Folder 2
FolderAnna Fali2026-02-15Open · Share
Document 2.1
87kbDocumentAnna Fali2026-02-20Open · Share
Text 2.2
200kbTextBernardo Dominic2026-03-20Open · Share
Picture 2.3
313kbPictureIoni Bowcher2026-04-20Open · Share
Video 2.4
426kbVideoStephen Shaw2026-05-20Open · Share
Document 2.5
539kbDocumentAmy Elsner2026-06-20Open · Share
scroll-frozen-columns-demo

Multiple columns can be frozen on both sides — pass alignFrozen="right" to pin to the right edge.

NameSizeKeyLevelHas ChildrenType
scroll-frozen-columns-multi-demo

Frozen Rows#

Keep specific nodes pinned above the scrollable body by rendering them inside DataTable.FrozenTBody.

NameSizeType
Folder 1
Folder
Document 1.1
50kbDocument
Text 1.2
163kbText
Picture 1.3
276kbPicture
Video 1.4
389kbVideo
scroll-frozen-rows-demo

Editing#

Both editMode="cell" and editMode="row" compose with treeMode. Editing state is keyed by the row key, so collapsing or expanding other branches never drops edits in flight.

Cell#

NameSizeType
Documents
75kb
Folder
Work
55kb
Folder
Expenses.doc
30kb
Document
Resume.doc
25kb
Document
cell-edit-demo

Cell editing composes with row selection.

Selected
NameSizeType
cell-edit-selection-demo

Row#

NameSizeTypeActions
Documents
75kb
Folder
row-edit-demo

Column Resize#

Resize works in tree mode via the resizableColumns prop with columnResizeMode (fit or expand).

Fit Mode#

NameSizeType
resize-demo

Expand Mode#

NameSizeType
resize-expand-demo

Column Reorder#

Drag and drop column headers to reorder columns.

NameSizeType
reorder-demo

Row Reorder#

Root-level row reordering via the drag handle on DataTable.RowReorder. Children stay attached to their parents.

Only root-level rows are reorderable; expand a node to see its children.

NameSizeType
row-reorder-demo

Column Toggle#

Show/hide columns and drag to reorder them in a popover.

NameSizeType
column-toggle-demo

Column Group#

Multi-level headers with rowSpan and colSpan, plus an aggregate TFoot.

ProductSale RateProfits
Last YearThis YearLast YearThis Year
Europe
60%
45%
$766,537$659,964
Bamboo Watch
51%
40%
$54,406$43,342
Black Watch
83%
9%
$423,132$312,122
Blue T-Shirt
49%
22%
$288,999$304,500
column-group-demo

Sort and filter work on any leaf header cell in a grouped layout — wrap the header in DataTable.Sort and add a filter row below the leaf row.

Sale RateProfits
Europe
60%
45%
$766,537$659,964
Bamboo Watch
51%
40%
$54,406$43,342
Black Watch
83%
9%
$423,132$312,122
Blue T-Shirt
49%
22%
$288,999$304,500
Americas
28%
42%
$655,563$508,832
Blue Band
38%
5%
$12,321$8,500
Bracelet
17%
79%
$643,242$500,332
column-group-filter-sort-demo

Filter#

Filtering uses the same filters + onFilter API as DataTable; treeMode honours it against the flattened tree. For the standalone hook used outside DataTable, see useTreeFilter.

Basic#

display="row" renders inline inputs directly under each column header and applies as the user types.

NameSizeType
filter-basic-demo

Advanced#

display="menu" swaps the inline input for a trigger icon that opens a popover with multiple constraints, match mode, operator, and Apply/Clear buttons.

Name
Size
Type
filter-advanced-demo

Export#

Only expanded (visible) rows are exported to CSV.

Only expanded (visible) rows are exported.
NameSizeType
export-demo

Lazy Loading#

Fetch each branch on demand when the user expands it.

NameSizeType
lazy-demo

Loading#

Overlay#

Click refresh to simulate a network fetch.
NameSizeType
loading-overlay-demo

Skeleton#

NameSizeType
loading-skeleton-demo

Empty State#

Use EmptyTBody for a custom empty-state view.

NameSizeType

No folders yet

Create your first folder to start building a tree.

empty-demo

Advanced#

Sort, filter (per-column + global), and cell editing composed in a single tree.

advanced-demo

API#

Sub-Components#

See DataTable Primitive for the full sub-component API — TreeTable uses the same primitives.

Hooks#

See useDataTable for the headless hook API.

Accessibility#

See DataTable Primitive for WAI-ARIA compliance details and keyboard support. Tree-specific ARIA attributes (aria-level, aria-expanded, aria-posinset, aria-setsize) are wired automatically.