ComponentsTree View

TreeView

A Tree View displays hierarchical structures. It also facilitates the exploration of categorical levels and their content.

Tree structures are built through composing the HvTreeItem component, or a custom variation of it.

It is based on the MUI X TreeView component.

GitHub LogoSource Code

Data object

Sometimes the tree data is in an object shape. These can be easily converted to HvTreeItem nodes using a recursive renderItem function.

Controlled

The tree view can be controlled by passing in expanded/onNodeToggle and selected/onNodeSelect props to control expansion and selection state respectively. When using multiSelect, the values and callbacks are of type string[], and string otherwise.

Loading data

Sometimes the full tree data is unknown or paginated. This sample showcases how a custom LoadingItem can be used to handle server-side tree data.

Custom tree view

The following example demonstrates a custom tree view that implements a common vertical navigation pattern.

  • Overview

  • Analytics