Create

General

Tree Grid

New
Copy page View as Markdown Open in ChatGPT Open in Claude

Rows with columns that nest into a tree and split into collapsible groups, with cells that hold any content.

Usage#

app.component.ts
import { WDS_TREE_GRID } from '@wds/angular/tree-grid';

Set columns on wds-tree-grid and render a wds-tree-grid-row per item, with a wds-tree-grid-cell per column (column is the column key). The tree comes from the order of the rows and their level: render a parent, then its sub-rows with a higher level. The grid adds the indent and the expand toggle to the tree column and hides the sub-rows of a collapsed row. Cells hold your own markup and components, so a cell can be a picker, a button or a link. To show plain records with paging, filtering and editing built in, use Data Table.

Examples#

Default#

Rows with a higher level under a row become its sub-rows: the first column gets the indent and the toggle. Collapse a row with the toggle or with ← on the focused row.

PlanningDana PikeNov 3Shortlist three sitesDana PikeOct 27Sign the leaseOmar BellNov 3Fit-outLena FoxNov 28NetworkTheo MarshNov 20Run the cablingTheo MarshNov 14Mount the access pointsTheo MarshNov 20Order desks and chairsLena FoxNov 21Moving dayOmar BellDec 5

Groups and row actions#

Each wds-tree-grid-group has a heading (label, count and actions slots), its own column headers and a footer. Here tasks are grouped by the status of the top-level task, and sub-tasks stay under their parent whatever their own status. Buttons in the actions slot of a cell and the menu slot of a row show on hover and focus; selected keeps them visible.

In progress2 Write the release notes In progressDelete Collect the merged changes To doDelete Draft the summary In progressDelete Update the onboarding guide In progressDeleteAdd taskTo do1 Plan the next sprint To doDelete Sort the backlog To doDeleteAdd task

Dragging, sorting and columns#

row-reorderable adds a grip to the rows and nestable lets a row be dropped onto another to become its sub-row. The grid does not move rows: wds-row-reorder gives the dragged row, the target row and the position (before, after or inside), and you render the new order; dropped onto a group outside its rows (also an empty group), target is empty and the row goes to the end of the group. Sortable headers fire wds-sort-change; resizable and reorderable change the column widths and order for all rows and groups at once.

DesignIvy Chen24 hWireframesIvy Chen10 hClickable prototypeMax Ortiz14 hBuildRae Lund60 hAPI endpointsRae Lund26 hScreensMax Ortiz34 hTestingNoor Haddad16 h

API References#

wds-tree-grid#

Tree grid: rows with columns that nest into a tree, optionally split into collapsible groups (WAI-ARIA Treegrid pattern). The grid lays out and labels what you put in it: you render wds-tree-grid-row elements with wds-tree-grid-cell children, so cells can hold any markup or framework component, and wrap them in wds-tree-grid-group elements to show them in groups. Rows form the tree by their order and level: a row followed by rows with a higher level is their parent and gets an expand toggle in the tree column. Collapsing a row hides its sub-rows. Columns come from columns. Every group repeats the header row, and all rows share the column widths. Sorting, resizing and reordering columns update sort-key, columnWidths and column-order and fire events; the grid does not sort or move rows itself: with row-reorderable it fires wds-row-reorder and you render the rows in the new order.

Attributes

AttributeTypeDefaultDescription
hidden-columns.hiddenColumnsstring[][]Keys of hidden columns.
column-order.columnOrderstring[][]Order of the columns (keys); columns missing here follow in the columns order.
tree-column.treeColumnstring''The column with the tree: indent and expand toggle (default: the first visible column).
sort-key.sortKeystring''Key of the sorted column (shown in its header).
sort-direction.sortDirectionWdsTreeGridSortDirection'asc'
resizablebooleanfalseColumns are resized by dragging the edge of their header.
reorderablebooleanfalseColumns are moved by dragging the grip in their header.
row-reorderable.rowReorderablebooleanfalseRows have a grip; dragging it fires wds-row-reorder.
nestablebooleanfalseWith row-reorderable: a row can also be dropped onto another row to become its sub-row.
densityWdsTreeGridDensity'default'
indentnumber24Indent of one tree level in px.
labelstring''Accessible name of the grid.

Properties

PropertyDescription
columnsWdsTreeGridColumn[]Column definitions.
columnWidthsRecord<string, number>Column widths in px set by resizing (column key → px); they override width.

Events

EventDescription
wds-sort-changeCustomEvent<WdsTreeGridSortChangeDetail>A sortable header was clicked: ascending, descending, then off.
wds-column-resizeCustomEvent<WdsTreeGridColumnResizeDetail>A column was resized (resizable), once the drag ends.
wds-column-reorderCustomEvent<WdsTreeGridColumnReorderDetail>A column was moved (reorderable).
wds-row-reorderCustomEvent<WdsTreeGridRowReorderDetail>A row was dragged onto another row, or onto a group outside its rows (an empty group: target is empty), with row-reorderable; move it in your data.
wds-row-toggleCustomEvent<WdsTreeGridRowToggleDetail>A row was expanded or collapsed (fired by the row).
wds-group-toggleCustomEvent<WdsTreeGridGroupToggleDetail>A group was expanded or collapsed (fired by the group).

Slots

SlotDescription
(default)wds-tree-grid-group elements, or wds-tree-grid-row elements without groups.

CSS parts (::part)

PartDescription
scrollerThe horizontally scrolling area.
headerThe row of column headers (without groups).

CSS custom properties

PropertyDescription
--wds-tree-grid-indentIndent of one level in the tree column (default indent, 24px).
--wds-tree-grid-group-gapSpace between groups (default 24px).

wds-tree-grid-group#

A collapsible group of rows in a wds-tree-grid: a heading with an expand toggle, the column headers and the rows. Every group repeats the column headers, and all groups share the column widths and order.

Attributes

AttributeTypeDefaultDescription
valuestring''Identifier of the group, passed in the grid's events.
labelstring''Name of the group read by screen readers on the toggle (default value).
expandedbooleantrueThe rows are shown.

Events

EventDescription
wds-group-toggleCustomEvent<WdsTreeGridGroupToggleDetail>The group was expanded or collapsed.

Slots

SlotDescription
(default)wds-tree-grid-row elements.
labelThe heading of the group, such as a badge.
countText after the heading, such as the number of rows.
actionsButtons after the heading, shown while the pointer is over the heading or focus is inside it.
footerContent under the rows, such as an Add button.

CSS parts (::part)

PartDescription
headingThe row with the toggle, label, count and actions.
headerThe row of column headers.
footerThe wrapper of the footer.

wds-tree-grid-row#

A row of a wds-tree-grid: wds-tree-grid-cell elements, one per column. level places the row in the tree; a row followed by rows with a higher level is their parent and gets an expand toggle in the tree column. Elements in the actions slot of a cell and in the menu slot of the row show while the pointer is over the row or focus is inside it.

Attributes

AttributeTypeDefaultDescription
valuestring''Identifier of the row, passed in the grid's events.
levelnumber1Level in the tree, from 1 (top level).
expandedbooleantrueSub-rows are shown.
selectedbooleanfalseThe row is highlighted and its actions stay visible.
labelstring''Name of the row read by screen readers on the grip and in announcements (default value).

Events

EventDescription
wds-row-toggleCustomEvent<WdsTreeGridRowToggleDetail>The row was expanded or collapsed.

Slots

SlotDescription
(default)wds-tree-grid-cell elements.
menuContent at the end of the row, such as a menu button.

CSS parts (::part)

PartDescription
gripThe drag handle (row-reorderable on the grid).

CSS custom properties

PropertyDescription
--wds-tree-grid-row-hoverBackground of a row under the pointer.
--wds-tree-grid-row-selectedBackground of a selected row.

wds-tree-grid-cell#

A cell of a wds-tree-grid-row, placed in the column named by column. The cell of the tree column also holds the indent of the row's level and the expand toggle. A cell of a hidden or unknown column is not shown.

Attributes

AttributeTypeDefaultDescription
columnstring''Key of the column the cell belongs to.
colspanstring''How many visible columns the cell spans from its own, or end for all the remaining width of the row.

Slots

SlotDescription
(default)Content of the cell.
actionsButtons at the end of the cell, shown while the pointer is over the row or focus is inside it.

CSS parts (::part)

PartDescription
contentThe wrapper of the content.
actionsThe wrapper of the actions.

Accessibility#

Screen reader#

The grid has role="treegrid" and each group role="rowgroup"; rows are row with aria-level and, for parents, aria-expanded. Cells are gridcell and headers columnheader with aria-sort.

One row is in the tab order at a time; the arrow keys move between rows. Buttons and fields inside cells keep their own tab stops.

Give rows a label: the grip and the move announcements use it instead of value. Moving rows and columns is announced in a live region.

Keyboard support#

KeyFunction
ArrowDownFocuses the next visible row.
ArrowUpFocuses the previous visible row.
ArrowRightExpands a collapsed row; on an expanded row focuses its first sub-row.
ArrowLeftCollapses an expanded row; otherwise focuses the parent row.
HomeFocuses the first row.
EndFocuses the last visible row.
Alt + ArrowUpWith row-reorderable, moves the row before its previous sibling.
Alt + ArrowDownWith row-reorderable, moves the row after its next sibling.
Alt + ArrowRightWith nestable, makes the row the last sub-row of its previous sibling.
Alt + ArrowLeftWith nestable, moves the row out of its parent, after it.
Footer