Skip to contents

Tree Grid

A hierarchical list of rows that contain buttons, inputs, and links, in one or more columns.

Note: Tree Grid is currently in preview. Its API may change before it becomes stable.

Projects
Website redesign
Mobile app

Usage guidelines

  • Avoid when rows hold no controls or columns: Use Tree instead when each item is a single element, including items that toggle like a checkbox or link to another page. Screen readers read a tree item as a whole, and users need fewer key presses.
  • Avoid for tabular data: Tree Grid doesn’t sort, resize, edit, or page through its rows. It doesn’t virtualize them yet either, so it renders a row for every item whose ancestors are expanded, including rows scrolled out of view. When users compare values across rows, use a data grid instead.
  • Give the tree grid an accessible name: Prefer <TreeGrid.Label>, or provide an aria-label on <TreeGrid.Table> when no visible label is rendered.
  • Name every control: Give each control inside a row a name that includes the item’s label, such as “Remove Wireframes”. Show what an input or a switch is for with visible text, such as a unit or a “Done” label, and keep that text in its name. Give <TreeGrid.Input> a visible <label>. The checkbox, expansion trigger, and clear button have English names, such as “Select Documents”, “Expand Documents”, and “Clear filter”: pass your own aria-label to translate them, based on state.expanded for the trigger.
  • Support touch screen readers: VoiceOver on iOS and TalkBack users can’t press arrow keys. Render <TreeGrid.RowExpansionTrigger>, and <TreeGrid.RowCheckbox> with checkbox selection, so they can expand and select rows by tapping.

Anatomy

Import the component and assemble its parts:

Anatomy

Without a header row, pass the render function to <TreeGrid.Table> directly instead of <TreeGrid.Collection>.

Item models

To add fields to the standard item, extend TreeGrid.DefaultItem and redeclare children with your own type. For any other item model, use TreeGrid.createItems(), and supply setChildren for nested edits and managed reparenting.

Custom item model

The root infers the item type from items. <TreeGrid.Table> and <TreeGrid.Collection> can’t see it and type items as any. Annotate the parameter of the render function, as (node: Node) does.

Controls inside rows

Each item is a row of one or more <TreeGrid.Cell>. Render the content of the item inside them, and its controls with <TreeGrid.CellButton>, <TreeGrid.CellInput>, <TreeGrid.CellLink>, <TreeGrid.RowCheckbox>, or <TreeGrid.CellControl>.

Controls inside a row

From a row, Arrow Right and Tab move to its controls, and Escape returns to the row.

A focused row announces its label, not its controls or the rest of its content.

  • Describe how to reach the controls with aria-description on the rows that have them, or once on <TreeGrid.Table> when most rows do.
  • Pass secondary content, such as a count or a status, to aria-describedby on <TreeGrid.Row>, or render it in its own column.

Base UI does not ship these strings. Translate them together with the rest of your interface.

To use a popup trigger as a control, pass it to the render prop of <TreeGrid.CellButton>:

Using popups with cell controls

Controls keep the keys they use, such as the caret keys of a text input or the up and down arrows of a popup trigger. Use the controlKeys prop to change which keys a control keeps. <TreeGrid.CellControl> keeps every key by default, so assign the key groups the tree should handle. For example, a custom rating widget that only uses the left and right arrows:

Custom control

The part must render the element that receives focus. Other focusable elements inside a row keep all of their keys, stay out of the row’s navigation, and add a tab stop to every row.

Examples

Multiple selection

Set multiple on <TreeGrid.Root> to let users select more than one row. A click or Space on a row adds or removes it, as does Enter on a row that can’t expand, and the selected items are an array.

Projects
Website redesign
Wireframes
Homepage copy
Mobile app
Login screen

Opt-in multiple selection

Use multiple="opt-in" when users opt in to selecting more than one row by holding a modifier key. Without one, a click or moving focus with the keyboard moves the selection to a single row. The modifier keys are the same as in Tree. On touch devices, a tap adds or removes a row, the same as multiple. A row with a checkbox always selects as with multiple.

Projects
Website redesign
Wireframes
Homepage copy
Mobile app
Login screen

Columns

Render a <TreeGrid.Cell> for each column in every row, and name the columns with <TreeGrid.HeaderCell> inside <TreeGrid.HeaderRow>. Every row needs a cell for each header cell, empty if needed. When icons name the columns, visually hide the header row instead of leaving it out.

Name
Size
Modified
Actions
src
17 KB
Mar 5
components
16 KB
Mar 5
Button.tsx
4 KB
Mar 3
Dialog.tsx
12 KB
Mar 5
index.ts
1 KB
Feb 27
package.json
2 KB
Mar 1
README.md
6 KB
Feb 20

Checkbox selection

Render <TreeGrid.RowCheckbox> inside <TreeGrid.Cell> to select a row with a checkbox, and <TreeGrid.RowCheckboxIndicator> inside it to show the state. Set multiple on <TreeGrid.Root> to allow more than one row to be selected. A click on the row toggles it, like a click on its checkbox.

The checkboxSelectionPropagation prop controls how a checkbox affects related rows. With descendants, checking a parent selects its whole branch. With parents, checking all of its selectable children selects the parent. Both are enabled by default with multiple selection. Pressing a row without a checkbox selects or deselects that row only.

Documents
Resume.pdf
Cover Letter.docx
Notes.txt

Render <TreeGrid.CellLink> inside <TreeGrid.Cell> to link a row to another page, and set active on the current page’s link.

When a link is the only control of a row, use <Tree.LinkItem> instead.

Animated expansion

Render <TreeGrid.GroupTransition> after each row, as in the anatomy, to animate expanding and collapsing branches. Use the --tree-group-transition-height CSS variable with the data-starting-style and data-ending-style attributes to animate the group’s height.

Filtering

Wrap <TreeGrid.Root> in <TreeGrid.FilterProvider> and add <TreeGrid.Input> inside the root.

Documents
Invoices
Invoice_Q1.pdf
Invoice_Q2.pdf

A match keeps its ancestors visible. Use mode to choose how the rows that don’t match are shown.

Rows match their label by default, ignoring case, accents, and punctuation, and receive a data-filter-match attribute. Screen readers don’t announce it, so describe matches with aria-description, as the demo does. Use filter to replace the matching: it receives each item’s label, the trimmed query, and the item. TreeGrid.useFilter() provides the same locale-aware comparisons:

Locale-aware prefix matching

To match rows on a server, pass the matches to filteredItems. Every match must also be in the items. To render the results yourself, pass filter={null} and give the root the filtered items.

Status messages

<TreeGrid.Status> politely announces the number of filter matches and of selected rows to screen readers. Keep it mounted and hide it visually, as the filtering demo does. The messages are in English. To translate them or write your own, pass the content as children, or a function that receives the latest change and its default message.

Updating items

Use actionsRef.current.applyTransaction() to add, update, move, or remove items without rebuilding items yourself, as the remove buttons of the demos above do. The operations apply in order, as a single change, and onItemsChange lists them in eventDetails.changes. With a controlled items, inserted rows render only once the parent passes them back. Set transactionThrottle to commit the transactions of a short window together.

Keyboard interactions

The stops of a row are its controls and, in a row of several cells, the cells without a control. On a row, the keys work as in Tree, except:

  • Arrow Right expands a collapsed row. On any other row, it moves focus to the first stop, or to the first child of an expanded row without stops.
  • Tab moves focus from the row through its controls, then out of the tree grid. Shift+Tab from the first control moves back to the row.
  • On a row with a <TreeGrid.RowCheckbox>, Space checks or unchecks the row, as does Enter when it can’t expand.
  • Enter follows the <TreeGrid.CellLink> of a row that can’t expand or be selected.

On a control or a cell, for the keys the control doesn’t keep:

  • Arrow Right and Arrow Left move focus to the next and previous stops. Arrow Left on the first stop moves back to the row. In a text input, they move the caret until it reaches the start or end of the text.
  • Arrow Down and Arrow Up move focus to the next and previous rows. In a row of several cells, focus stays in the same column. With multiple="opt-in", the selection follows.
  • Home and End move focus to the first and last stops of the row. With Ctrl or Cmd, in a row of several cells, they move to the same column in the first and last rows.
  • Esc moves focus back to the row, and doesn’t reach a popup or dialog around the tree grid.
  • Space on a cell selects the row, as on the row.

Space, Enter, and typed characters always belong to the control. To choose which of the other keys it keeps, see Controls inside rows. In right-to-left layouts, Arrow Right and Arrow Left swap.

API reference

FilterProvider

Enables filtering for the tree it wraps. Add an Input inside the root to edit the query. Doesn’t render its own HTML element.

defaultValuestring''
Description

The filter query when the tree is initially rendered. To render a controlled query, use the value prop instead.

Type
Default
''
valuestring—
Name
Description

The filter query. To render an uncontrolled query, use the defaultValue prop instead.

Type
onValueChangefunction—
Description

Event handler called when the filter query changes.

Type
filterUnion—
Name
Description

Filter function used to match items against the query. Receives each item’s label, the trimmed query, and the item, and keeps the item when it returns true. By default, items match when their label contains the query, ignoring case, accents, and punctuation. A new function matches every item again, so keep it stable across renders. Pass null when rendering filtered items yourself.

Type
filteredItemsany[]—
Description

The items matching the query, for filtering done outside the tree, such as on a server. Replaces filter when set, and an empty array matches nothing. Each item must also be in the tree’s items.

Type
localeIntl.LocalesArgument—
Name
Description

Locale used when comparing an item against the query. Defaults to the runtime’s default locale.

Type
modeTreeGrid.FilterMode'hide-non-matches'
Name
Description

How the tree presents the items that don’t match.

  • 'hide-non-matches': shows only the matches, their ancestors, and their descendants.
  • 'collapse-non-matches': shows every item, collapsing the branches without matches.
  • 'expand-matches': shows every item, expanding the branches with matches.

The expansion the filter forces doesn’t change expandedItems.

Type
Default
'hide-non-matches'
childrenReact.ReactNode—
Type

TreeGrid.FilterProvider.PropsHide

Re-Export of FilterProvider props as TreeGridFilterProviderProps

TreeGrid.FilterProvider.StateHide

TreeGrid.FilterProvider.ChangeEventReasonHide

TreeGrid.FilterProvider.ChangeEventDetailsHide

Root

Groups all parts of the tree grid. Doesn’t render its own HTML element.

actionsRefReact.RefObject<TreeGrid.Root.Actions<TItem> | null>—
Description

A ref to imperative actions on the tree.

Type
checkboxSelectionPropagationTreeGrid.CheckboxSelectionPropagation{ parents: true, descendants: true }
Description

Controls how checking an item, with its checkbox or with setItemSelection(), propagates through the hierarchy. Pressing an item without a checkbox, replacing the selection, or selecting a range doesn’t propagate.

When checkboxSelectionPropagation.descendants is set to true:

  • Selecting a parent selects all its descendants automatically.
  • Deselecting a parent deselects all its descendants automatically.

When checkboxSelectionPropagation.parents is set to true:

  • Selecting all descendants of a parent selects the parent automatically.
  • Deselecting a descendant of a selected parent deselects the parent automatically.
Default
{ parents: true, descendants: true }
defaultExpandedItemsTreeGrid.ItemId[][]
Description

The items that are initially expanded.

To render a controlled component, use the expandedItems prop instead.

Type
Default
[]
defaultItemsTreeGrid.Root.Items<TItem>—
Description

The item data used for an uncontrolled component on its initial render. Accepts the same data as items.

Type
defaultSelectedItemsUnion—
Description

The items that are initially selected. With multiple selection, null is the same as []. Defaults to null with single selection and [] with multiple selection.

To render a controlled component, use the selectedItems prop instead.

Type
disableEmptySelectionbooleanfalse
Description

Whether the user is prevented from deselecting the last selected item. An empty initial or controlled selection is still allowed.

Type
Default
false
expandOnClickbooleanfalse
Description

Whether clicking anywhere on an item row toggles expansion. When false, clicking the row does not toggle expansion; clicking its expansion trigger does.

Type
Default
false
expandedItemsTreeGrid.ItemId[]—
Description

The expanded items.

To render an uncontrolled component, use the defaultExpandedItems prop instead.

Type
itemFocusableWhenDisabledbooleantrue
Description

Whether disabled items should be focusable. A disabled tree leaves the tab order whatever this prop is.

Type
Default
true
itemsTreeGrid.Root.Items<TItem>—
Name
Description

The controlled item data. Pass a standard item array, or a collection returned by createItems() for a custom item model. A model that extends the standard item must redeclare children with its own type.

Type
multipleboolean | 'opt-in'false
Description

Whether multiple items can be selected, and how selecting an item affects the current selection.

  • false: only one item can be selected.
  • true: each item is toggled independently.
  • 'opt-in': selecting an item moves the current selection to it, and users hold a modifier key to select more than one item. It behaves like true on touch devices, where there are no modifier keys, and for items with a checkbox.
Type
Default
false
onExpandedItemsChangefunction—
Description

Event handler called when items are expanded or collapsed.

The event reason is 'list-navigation' for Arrow Right, Arrow Left and *, and 'missing' when expanded items are removed by a transaction. Automatic changes cannot be canceled; calling eventDetails.cancel() for 'missing' has no effect.

Type
onItemExpansionTogglefunction—
Description

Event handler called when an item is expanded or collapsed.

Type
onItemHighlightedfunction—
Description

Event handler called when an item is highlighted (it receives focus, or one of its controls does) or unhighlighted. Receives the highlighted item’s id, or undefined when no item is highlighted anymore, such as when focus leaves the tree.

The event reason is 'keyboard' when a key press moved focus, 'pointer' when a press did, and 'none' otherwise, such as when tabbing into or out of the tree, calling actionsRef.focusItem(), or when focus moves away from a removed item.

Type
onItemSelectionTogglefunction—
Description

Event handler called when an item is selected or deselected.

Type
onItemsChangefunction—
Description

Event handler called when the items change. Fires when items are added, removed, moved, or updated, so controlled hierarchies can persist every edit.

Type
onSelectedItemsChangefunction—
Description

Event handler called when the selected items change.

The event reason is 'list-navigation' when a key that moves focus, or Ctrl+A, changes the selection, 'missing' when selected items are removed by a transaction, and 'none' when the tree re-applies checkbox propagation after its items change, such as when a checked folder loads its children. Automatic changes cannot be canceled; calling eventDetails.cancel() for 'missing' or 'none' has no effect.

Type
selectedItemsUnion—
Description

The selected items. With multiple selection, null is the same as [].

To render an uncontrolled component, use the defaultSelectedItems prop instead.

Type
transactionThrottlenumber0
Description

The minimum time between two commits of actionsRef.applyTransaction(), in milliseconds. The first transaction after a quiet period commits at once. The ones that follow within the window are applied together, as a single items change, when the window ends. Until then, the actions and the rendered items show the items as the last commit left them. Call actionsRef.flushTransactions() to commit them right away.

Type
Default
0
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
childrenReact.ReactNode—
Description

The children of the component.

Type

TreeGrid.Root.PropsHide

Re-Export of Root props as TreeGridRootProps

TreeGrid.Root.StateHide

TreeGrid.Root.ActionsHide

TreeGrid.Root.HighlightEventReasonHide

TreeGrid.Root.HighlightEventDetailsHide

TreeGrid.Root.ExpansionChangeEventDetailsHide

TreeGrid.Root.ExpansionChangeEventReasonHide

TreeGrid.Root.ItemExpansionToggleEventDetailsHide

TreeGrid.Root.ItemExpansionToggleValueHide

TreeGrid.Root.ItemsHide

TreeGrid.Root.ItemsChangeEventDetailsHide

TreeGrid.Root.ItemsChangeEventReasonHide

TreeGrid.Root.ItemSelectionToggleEventDetailsHide

TreeGrid.Root.ItemSelectionToggleValueHide

TreeGrid.Root.SelectionChangeEventDetailsHide

TreeGrid.Root.SelectionChangeEventReasonHide

Label

An accessible label that is automatically associated with the tree. Clicking it focuses the tree. Renders a <div> element.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.Label.PropsHide

Re-Export of Label props as TreeGridLabelProps

TreeGrid.Label.StateHide

Input

A search field that filters the tree. Requires the root to be wrapped in FilterProvider. Renders an <input> element.

disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the input is disabled.

Attribute
Description
data-disabled

Present when the input is disabled.

TreeGrid.Input.PropsHide

Re-Export of Input props as TreeGridInputProps

TreeGrid.Input.StateHide

Clear

A button that clears the input text. Requires the root to be wrapped in FilterProvider. Renders a <button> element when the input has text.

nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the button is disabled.

Attribute
Description
data-disabled

Present when the button is disabled.

TreeGrid.Clear.PropsHide

Re-Export of Clear props as TreeGridClearProps

TreeGrid.Clear.StateHide

Status

Displays a status message whose content changes are announced politely to screen readers. By default, announces in English the number of items matching the filter, and the number of selected items after a press or a key changes a multiple selection. Screen readers announce the state of the item itself. Pass a function as children to build the message from change in another language. This component’s root element must remain mounted in the DOM to announce changes consistently across screen readers. Avoid hiding or removing the component itself with display: none, hidden, aria-hidden, or conditional rendering. Prefer updating or conditionally rendering its children instead. Renders a <div> element.

children| React.ReactNode
| ((state: TreeGrid.Status.State) => React.ReactNode)
—
Description

The status content, or a function that receives the state and returns it. Defaults to the English message of the latest change.

Type
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.Status.PropsHide

Re-Export of Status props as TreeGridStatusProps

TreeGrid.Status.StateHide

TreeGrid.Status.ChangeHide

TreeGrid.Status.FilterChangeHide

TreeGrid.Status.SelectionChangeHide

Empty

Renders its children only when the tree has no visible rows, or when no item matches the filter. Announces changes politely to screen readers. This component’s root element must remain mounted in the DOM to announce changes consistently across screen readers. Avoid hiding or removing the component itself with display: none, hidden, aria-hidden, or conditional rendering. Prefer updating or conditionally rendering its children instead. Renders a <div> element.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.Empty.PropsHide

Re-Export of Empty props as TreeGridEmptyProps

TreeGrid.Empty.StateHide

Table

The tree grid, which contains the header row and the rows. Pass a function as children to render the row of each item. With a header row, render <TreeGrid.HeaderRow> and <TreeGrid.Collection> inside instead. Renders a <div> element with role="treegrid".

children| React.ReactNode
| ((item: any) => React.ReactNode)
—
Description

The render function for the row of each item, or the header row and the collection of rows. Annotate the item parameter to type it.

Type
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the tree grid is disabled.

data-empty

Present when the tree grid has no visible rows, or no item matches the filter.

Attribute
Description
data-disabled

Present when the tree grid is disabled.

data-empty

Present when the tree grid has no visible rows, or no item matches the filter.

TreeGrid.Table.PropsHide

Re-Export of Table props as TreeGridTableProps

TreeGrid.Table.StateHide

HeaderRow

The row of column headers, which names the columns for assistive technology. Place it in TreeGrid.Table, before TreeGrid.Collection. Renders a <div> element with role="row".

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.HeaderRow.PropsHide

Re-Export of HeaderRow props as TreeGridHeaderRowProps

TreeGrid.HeaderRow.StateHide

HeaderCell

The header of a column, which screen readers announce when focus enters one of its cells. Render one per column, in the order of the cells. Renders a <div> element with role="columnheader".

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.HeaderCell.PropsHide

Re-Export of HeaderCell props as TreeGridHeaderCellProps

TreeGrid.HeaderCell.StateHide

Collection

Renders the row of each item, after the header row. Doesn’t render its own HTML element.

Without a header row, pass the function to TreeGrid.Table instead, which renders it the same way.

children*(item: any) => React.ReactNode—
Description

The render function for the row of each item. Annotate the item parameter to type it.

Type

TreeGrid.Collection.PropsHide

Re-Export of Collection props as TreeGridCollectionProps

TreeGrid.Collection.StateHide

Row

An item in a tree, and a row in a tree grid. Renders a <div> element.

itemId*TreeGrid.ItemId—
Name
Description

The id of the item.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-selected

Present when the item is selected.

data-highlighted

Present when the item is highlighted: it has focus, or, in a tree grid, one of its controls does.

data-disabled

Present when the item is disabled.

data-collapsed

Present when the item is collapsed.

data-expandable

Present when the item can be expanded.

data-expanded

Present when the item is expanded.

data-filter-match

Present when the item is an exact filter match.

data-item-id

The id of the item.

Attribute
Description
data-selected

Present when the item is selected.

data-highlighted

Present when the item is highlighted: it has focus, or, in a tree grid, one of its controls does.

data-disabled

Present when the item is disabled.

data-collapsed

Present when the item is collapsed.

data-expandable

Present when the item can be expanded.

data-expanded

Present when the item is expanded.

data-filter-match

Present when the item is an exact filter match.

data-item-id

The id of the item.

--tree-item-level

The level of the item in the tree hierarchy (1-based, matches aria-level).

CSS Variable
Description
--tree-item-level

The level of the item in the tree hierarchy (1-based, matches aria-level).

TreeGrid.Row.PropsHide

Re-Export of Row props as TreeGridRowProps

TreeGrid.Row.StateHide

Cell

A cell of a row, which holds content and controls. In a row of several cells, the arrow keys also stop at each cell without a control. Requires TreeGrid.Root. Renders a <div> element with role="gridcell".

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

TreeGrid.Cell.PropsHide

Re-Export of Cell props as TreeGridCellProps

TreeGrid.Cell.StateHide

RowIndentGuide

Renders vertical indent guide lines for a tree item, one per ancestor level. Each line carries data-level and, when its ancestor is a last child, data-last. Renders a <span> element containing inner <span> elements.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-last

Present when the ancestor at this guide’s depth is the last child of its parent. Use it to truncate the guide line.

data-level

The level of the ancestor this guide line belongs to, from 1 for the root items, like its aria-level.

Attribute
Description
data-last

Present when the ancestor at this guide’s depth is the last child of its parent. Use it to truncate the guide line.

data-level

The level of the ancestor this guide line belongs to, from 1 for the root items, like its aria-level.

--tree-indent-guide-level

The level of the ancestor this guide line belongs to, from 1 for the root items, like its aria-level. Set on each inner <span> within the indent guide wrapper.

CSS Variable
Description
--tree-indent-guide-level

The level of the ancestor this guide line belongs to, from 1 for the root items, like its aria-level. Set on each inner <span> within the indent guide wrapper.

TreeGrid.RowIndentGuide.PropsHide

Re-Export of RowIndentGuide props as TreeGridRowIndentGuideProps

TreeGrid.RowIndentGuide.StateHide

RowExpansionTrigger

A button that toggles the expansion state of a tree item. Alt-click (Option-click on macOS) toggles its descendants too. Renders a <button> element when the item can be expanded. In a link item, renders a <span> that only handles clicks, since a link can’t contain a button. Keyboard users expand the item with the arrow keys.

nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
disabledbooleanfalse
Description

Whether the component should ignore user interaction. The trigger is also disabled while its item or the tree is disabled.

Type
Default
false
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the trigger, its item, or the tree is disabled.

data-collapsed

Present when the item is collapsed.

data-expanded

Present when the item is expanded.

Attribute
Description
data-disabled

Present when the trigger, its item, or the tree is disabled.

data-collapsed

Present when the item is collapsed.

data-expanded

Present when the item is expanded.

TreeGrid.RowExpansionTrigger.PropsHide

Re-Export of RowExpansionTrigger props as TreeGridRowExpansionTriggerProps

TreeGrid.RowExpansionTrigger.StateHide

RowCheckbox

A checkbox that controls selection for its tree item. Requires TreeGrid.Root. Renders a <span> element and a hidden <input> beside it.

nativeButtonbooleanfalse
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.

Type
Default
false
inputRefReact.Ref<HTMLInputElement>—
Description

A ref to access the hidden <input> element.

Type
idstring—
Name
Description

The id of the hidden input element.

Type
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-checked

Present when the checkbox is checked.

data-unchecked

Present when the checkbox is not checked.

data-disabled

Present when the item is disabled or cannot be selected.

data-indeterminate

Present when the item is not selected but some of its selectable descendants are.

Attribute
Description
data-checked

Present when the checkbox is checked.

data-unchecked

Present when the checkbox is not checked.

data-disabled

Present when the item is disabled or cannot be selected.

data-indeterminate

Present when the item is not selected but some of its selectable descendants are.

TreeGrid.RowCheckbox.PropsHide

Re-Export of RowCheckbox props as TreeGridRowCheckboxProps

TreeGrid.RowCheckbox.StateHide

RowCheckboxIndicator

Renders when the tree item checkbox is checked or mixed. Renders a <span> element.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
keepMountedbooleanfalse
Description

Whether to keep the element in the DOM when the checkbox is not checked.

Type
Default
false
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-checked

Present when the checkbox is checked.

data-unchecked

Present when the checkbox is not checked.

data-disabled

Present when the item is disabled or cannot be selected.

data-indeterminate

Present when the item is not selected but some of its selectable descendants are.

data-starting-style

Present when the indicator is animating in.

data-ending-style

Present when the indicator is animating out.

Attribute
Description
data-checked

Present when the checkbox is checked.

data-unchecked

Present when the checkbox is not checked.

data-disabled

Present when the item is disabled or cannot be selected.

data-indeterminate

Present when the item is not selected but some of its selectable descendants are.

data-starting-style

Present when the indicator is animating in.

data-ending-style

Present when the indicator is animating out.

TreeGrid.RowCheckboxIndicator.PropsHide

Re-Export of RowCheckboxIndicator props as TreeGridRowCheckboxIndicatorProps

TreeGrid.RowCheckboxIndicator.StateHide

RowGroupIndicator

A visual indicator for expandable tree items. Renders a <span> element when the item can be expanded.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-collapsed

Present when the item is collapsed.

data-expanded

Present when the item is expanded.

Attribute
Description
data-collapsed

Present when the item is collapsed.

data-expanded

Present when the item is expanded.

TreeGrid.RowGroupIndicator.PropsHide

Re-Export of RowGroupIndicator props as TreeGridRowGroupIndicatorProps

TreeGrid.RowGroupIndicator.StateHide

A link inside a tree item that takes part in the item’s keyboard navigation. Requires TreeGrid.Root. Renders an <a> element.

activebooleanfalse
Name
Description

Whether the link is the currently active page. Marks the link and its item with aria-current="page", and gives the item the tree’s tab stop when no item is selected and no other item had focus.

Type
Default
false
controlKeysTreeGrid.CellControl.Keys—
Description

Which keys the link handles itself instead of the tree. By default, the arrows, Home, End, and Escape navigate the tree.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the link is disabled, because its item or the tree is.

data-active

Present when the link is the currently active page.

Attribute
Description
data-disabled

Present when the link is disabled, because its item or the tree is.

data-active

Present when the link is the currently active page.

TreeGrid.CellLink.PropsHide

Re-Export of CellLink props as TreeGridCellLinkProps

TreeGrid.CellLink.StateHide

CellInput

An input inside a tree item that takes part in the item’s keyboard navigation. Requires TreeGrid.Root. Renders an <input> element.

defaultValueUnion—
Description

The default value of the input. Use when uncontrolled.

Type
controlKeysTreeGrid.CellControl.Keys—
Description

Which keys the input handles itself instead of the tree. By default, the input keeps Home and End. A text input keeps the Left and Right arrows until the caret reaches the start or end of its text. Other inputs keep them, including email and number inputs, which don’t expose their caret. The Up and Down arrows move between items unless the input uses them, like a number or date input.

focusableWhenDisabledbooleantrue
Description

Whether the input remains focusable when disabled. A disabled input that remains focusable is read-only, and still submits its value with a form. Otherwise it is natively disabled, and a form doesn’t submit its value.

Type
Default
true
disabledbooleanfalse
Description

Whether the input is disabled. The input is also disabled while its item or the tree is disabled.

Type
Default
false
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the input is disabled.

data-focusable

Present when the input remains focusable when disabled.

Attribute
Description
data-disabled

Present when the input is disabled.

data-focusable

Present when the input remains focusable when disabled.

TreeGrid.CellInput.PropsHide

Re-Export of CellInput props as TreeGridCellInputProps

TreeGrid.CellInput.StateHide

CellButton

A button inside a tree item that takes part in the item’s keyboard navigation. Requires TreeGrid.Root. Renders a <button> element.

controlKeysTreeGrid.CellControl.Keys—
Description

Which keys the button handles itself instead of the tree. By default, the arrows, Home, End, and Escape navigate the tree. A popup trigger keeps the Up and Down arrows so it can open its popup.

focusableWhenDisabledbooleantrue
Description

Whether the button remains focusable when disabled.

Type
Default
true
nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
disabledbooleanfalse
Description

Whether the button should ignore user interaction. The button is also disabled while its item or the tree is disabled.

Type
Default
false
classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the button is disabled.

data-focusable

Present when the button remains focusable when disabled.

Attribute
Description
data-disabled

Present when the button is disabled.

data-focusable

Present when the button remains focusable when disabled.

TreeGrid.CellButton.PropsHide

Re-Export of CellButton props as TreeGridCellButtonProps

TreeGrid.CellButton.StateHide

CellControl

Adds any focusable element inside a tree item to the item’s keyboard navigation. Requires TreeGrid.Root. Renders a <div> element.

controlKeysTreeGrid.CellControl.Keys—
Description

Which keys the control handles itself instead of the tree. By default, the control keeps every key. Assign a key group to 'tree' to let it navigate the item and the tree.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-disabled

Present when the control’s item or the tree is disabled.

Attribute
Description
data-disabled

Present when the control’s item or the tree is disabled.

TreeGrid.CellControl.PropsHide

Re-Export of CellControl props as TreeGridCellControlProps

TreeGrid.CellControl.StateHide

TreeGrid.CellControl.KeysHide

GroupTransition

A wrapper that animates a group of tree items while it expands or collapses. Rendering this part next to an item enables transitions for that item’s children, which render inside it. Renders null while the group is not animating. Renders a <div> element.

classNamestring | function—
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function—
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function—
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-collapsing

Present while the group animates its items out, as its parent collapses.

data-expanding

Present while the group animates its items in, as its parent expands.

data-parent-id

The id of the item whose children the group contains.

data-starting-style

Present when the group is animating in.

data-ending-style

Present when the group is animating out.

Attribute
Description
data-collapsing

Present while the group animates its items out, as its parent collapses.

data-expanding

Present while the group animates its items in, as its parent expands.

data-parent-id

The id of the item whose children the group contains.

data-starting-style

Present when the group is animating in.

data-ending-style

Present when the group is animating out.

--tree-group-transition-height

The height of the animated group of tree items.

CSS Variable
Description
--tree-group-transition-height

The height of the animated group of tree items.

TreeGrid.GroupTransition.PropsHide

Re-Export of GroupTransition props as TreeGridGroupTransitionProps

TreeGrid.GroupTransition.StateHide

useFilter

Matches items against a query using Intl.Collator for robust string matching. This hook is used when customizing how items match. Call its methods inside the filter prop of <TreeGrid.FilterProvider>.

Parameters

TreeGrid.FilterOptions

localeIntl.LocalesArgument
Name
Description

The locale to use for string comparison. Defaults to the user’s runtime locale.

Type

Return value

TreeGrid.Filter

containsfunction
Description

Returns whether the text contains the query.

Type
startsWithfunction
Description

Returns whether the text starts with the query.

Type
endsWithfunction
Description

Returns whether the text ends with the query.

Type

createItems

Normalizes a custom item model into a collection for the items prop of <TreeGrid.Root>, deriving each item’s ID, label, and children. Create static collections at module scope, and memoize dynamic collections by their data and every value their accessors read.

Parameters

data*TItem[]—
Name
Description

The items to render, or undefined when there are none yet.

Type
options*CreateTreeGridItemsOptions<TItem>—
Description

Accessors that read and update the item model.

Return value

Additional types

CreateTreeGridItemsOptionsHide

TreeGrid.CheckboxSelectionPropagationHide

TreeGrid.DefaultItemHide

TreeGrid.FilterHide

TreeGrid.FilterModeHide

TreeGrid.FilterOptionsHide

TreeGrid.ItemChangeHide

TreeGrid.ItemDestinationHide

TreeGrid.ItemIdHide

TreeGrid.ItemPositionHide

TreeGrid.ItemTransactionHide

TreeGridCellButtonDataAttributesHide

TreeGridCellControlDataAttributesHide

TreeGridCellInputDataAttributesHide

TreeGridCellLinkDataAttributesHide

TreeGridClearDataAttributesHide

TreeGridGroupTransitionCssVariablesHide

TreeGridGroupTransitionDataAttributesHide

TreeGridInputDataAttributesHide

TreeGridRowCheckboxDataAttributesHide

TreeGridRowCheckboxIndicatorDataAttributesHide

TreeGridRowCssVariablesHide

TreeGridRowDataAttributesHide

TreeGridRowExpansionTriggerDataAttributesHide

TreeGridRowGroupIndicatorDataAttributesHide

TreeGridRowIndentGuideCssVariablesHide

TreeGridRowIndentGuideDataAttributesHide

TreeGridTableDataAttributesHide