Balance Logo
Balance
Reckon Design System
Open playroom

Tree View

The tree view presents a hierarchical list.
Install
pnpm add @balance-web/tree-view
Import usage
import {
flattenTreeData,
TreeView
} from '@balance-web/tree-view';
  • Code
  • API

A tree view presents a hierarchical list.

Usage

The TreeView component will handle the expand/collapse behaviour.

NOTE: It's important that we use React.useMemo (ref) when flattening our data to ensure that it isn't recreated on every render. Otherwise the component will behave unexpectedly.

Edit in Playroom

Selection

Use the onSelect and isSelected properties to manage node selection.

NOTE: The component uses the id property internally to track branches, so you must use another key to identify nodes. In this example we're using nodeID.

Rendering

Using the nodeRenderer compose Balance components to create the desired interface.

NOTE: It's important that we use React.useCallback (ref) when creating our nodeRenderer to ensure that it isn't recreated on every render. Otherwise you could see performance issues.

Copyright © 2024 Reckon. Designed and developed in partnership with Thinkmill.
Bitbucket logoJira software logoConfluence logo