TreeGrid is used to create a tree hierarchy.
It is not a visually styled component, but instead helps with adding
keyboard navigation and roving tab index behaviors to tree grid structures.
A tree grid is a hierarchical 2 dimensional UI component, for example it could be used to implement a file system browser.
A tree grid allows the user to navigate using arrow keys. Up/down to navigate vertically across rows, and left/right to navigate horizontally between focusables in a row.
The TreeGrid renders both a table and tbody element, and is intended to be used
with TreeGridRow (tr) and TreeGridCell (td) to build out a grid.
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
applicationAriaLabel |
Label to use for the element with the | |
children Required |
The children to be rendered in the tree grid. | |
onExpandRow | () => {} |
Callback to fire when row is expanded. |
onCollapseRow | () => {} |
Callback to fire when row is collapsed. |
onFocusRow | () => {} |
Callback that fires when focus is shifted from one row to another via the Up and Down keys. Callback is also fired on Home and End keys which move focus from the beginning row to the end row. The callback is passed the event, the start row element that the focus was on originally, and the destination row element after the focus has moved. |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = () => <TreeGrid onExpandRow={fn()} onCollapseRow={fn()} onFocusRow={fn()}><Rows items={ groceries } /></TreeGrid>;