ComponentsEnterpriseTreeView

TreeView

TreeView presents hierarchical enterprise content with predictable expansion, selection, and keyboard navigation.

WAI-ARIA treeControlled APIMulti-selectKeyboard navigation3 sizes

Overview

Use TreeView to help people inspect and navigate hierarchical data without losing the relationship between parents, children, and siblings.

Workspace hierarchy

Live preview

Expand the workspace and select either project in this live preview.

Enterprise workspace12 items12
Migration programUpdated today
Identity refreshUpdated yesterday
WorkspaceTree.tsx
tsx
import { TreeView, type TreeViewNode } from 'omverse-ui'
 
const nodes: TreeViewNode[] = [
{
id: 'workspace',
label: 'Enterprise workspace',
icon: 'folder-open',
children: [
{ id: 'projects', label: 'Projects', icon: 'folder', children: projectNodes },
{ id: 'reports', label: 'Reports', icon: 'folder', badge: '4' },
],
},
]
 
<TreeView
variant="bordered"
label="Workspace navigation"
nodes={nodes}
selectedIds={selectedIds}
onSelectionChange={setSelectedIds}
defaultExpandedIds={['workspace', 'projects']}
/>

Anatomy

TreeView rows combine disclosure, identifying visuals, labels, supporting metadata, status, and nested hierarchy.

⌄▣ProjectsWorkspace4
▤MigrationUpdated today
12345
  1. 1
    Disclosure

    Expands or collapses a parent node without changing selection.

  2. 2
    Node icon

    Helps distinguish containers, documents, and domain objects.

  3. 3
    Label and metadata

    Identifies the node and adds concise supporting context.

  4. 4
    Status

    Shows a count, state, or other compact supplementary value.

  5. 5
    Child group

    Uses indentation and a guide to preserve parent-child relationships.

When to use

Use TreeView when hierarchy is essential to understanding or choosing an item.

Recommended

  • Navigate nested resources

    Use for workspaces, folders, taxonomies, organization units, or governed assets.

  • Preserve visible context

    Let people inspect nearby parents and siblings while moving through a hierarchy.

  • Support hierarchical selection

    Use when one or several nodes must be chosen from multiple levels.

When not to use

Prefer flatter patterns when hierarchy does not materially help the task.

Avoid

  • Do not use for short navigation

    Use Navbar, Tabs, or a simple link list for a small set of destinations.

  • Do not hide unrelated categories

    Use Accordion when sections are independent rather than hierarchical.

  • Do not represent tabular relationships

    Use DataTable when comparison across columns is the primary task.

Variants

Surface and density options adapt TreeView to navigation panels, inspectors, and contained enterprise cards.

Plain

Fits within a sidebar or panel that already provides containment.

Bordered

Defines a self-contained hierarchy on open surfaces.

Raised

Separates the hierarchy from layered or scrolling content.

Sizes

Small, medium, and large adjust density while retaining usable targets.

States

Each node communicates expansion, selection, focus, availability, and asynchronous loading independently.

StateTriggerVisual responseInteraction
CollapsedParent children are hiddenRight-pointing disclosureRight Arrow or disclosure expands
ExpandedChildren are visibleDownward disclosure and nested groupLeft Arrow collapses
SelectedNode belongs to the selectionPrimary-container state layerSpace toggles selection
FocusedNode is keyboard-activeVisible focus ringArrow keys move focus
LoadingChildren are being retrievedProgress indicator beside the nodeExpansion waits for content
DisabledNode is unavailableReduced emphasisDiscoverable but not selectable
EmptyNo nodes are availableNamed empty messageNo tree navigation

Behavior

TreeView maintains separate expansion, selection, and active-focus state so applications can control each concern independently.

Linear focus

Up and Down move through only the currently visible nodes.

Hierarchy movement

Right expands or enters children; Left collapses or returns to the parent.

Selection

Single and multiple modes update independently from disclosure.

Lazy content

Loading nodes remain stable while their children are retrieved.

Accessibility

TreeView follows the WAI-ARIA tree pattern with one active tab stop, hierarchical roles, announced selection, and complete keyboard movement.

KeyAction
↑↓Moves to the previous or next visible node.
→Expands a closed parent or moves to its first child.
←Collapses an open parent or moves to its parent.
HomeEndMoves to the first or last visible node.
SpaceToggles selection according to selectionMode.
EnterSelects and activates the focused enabled node.
  • Give the tree a concise accessible label.
  • Use tree, treeitem, and group roles to preserve hierarchy.
  • Expose expanded, selected, disabled, busy, position, and set-size states.
  • Keep exactly one visible node in the Tab sequence.
  • Do not rely on indentation or icons alone to communicate hierarchy.
  • Keep disabled nodes discoverable without allowing activation.

Content guidelines

Node labels and metadata should remain short enough to scan at several levels of indentation.

Use object names

Label nodes with the resource people recognize.

ExampleMigration program

Keep siblings parallel

Use the same naming pattern for nodes at one level.

ExampleProjects, Reports, Archive

Make metadata useful

Add one short detail that helps distinguish similar items.

ExampleUpdated today

Use compact badges

Reserve badges for counts or terse states.

Example4

Examples

Multiple selection is appropriate when people apply one operation to nodes across several branches.

Interactive workspace tree

Live preview

The preview demonstrates disclosure and single selection in a compact hierarchy.

Enterprise workspace12 items12
Migration programUpdated today
Identity refreshUpdated yesterday
ReportFolderTree.tsx
tsx
<TreeView
label="Choose report folders"
nodes={nodes}
selectionMode="multiple"
defaultSelectedIds={['audit', 'risk']}
onSelectionChange={setFolderIds}
/>

Props / API

TreeView extends div attributes; each TreeViewNode supplies identity, content, optional hierarchy, and availability state.

Props

PropTypeDefaultDescription
nodesreadonly TreeViewNode[]requiredHierarchical node definitions.
labelstringrequiredAccessible name announced for the tree.
selectionMode'none' | 'single' | 'multiple''single'Determines whether and how nodes can be selected.
selectedIdsreadonly string[]undefinedControlled selected node identifiers.
defaultSelectedIdsreadonly string[][]Initial uncontrolled selection.
onSelectionChange(ids: readonly string[]) => voidundefinedRuns whenever selection changes.
expandedIdsreadonly string[]undefinedControlled expanded node identifiers.
defaultExpandedIdsreadonly string[][]Initial uncontrolled expansion.
onExpandedChange(ids: readonly string[]) => voidundefinedRuns whenever expansion changes.
activeIdstringundefinedControlled keyboard-active node.
defaultActiveIdstringfirst nodeInitial uncontrolled active node.
onActiveChange(id: string) => voidundefinedRuns when keyboard focus moves.
onNodeActivate(node: TreeViewNode) => voidundefinedRuns when Enter activates an enabled node.
emptyStateReactNode'No items available.'Content shown when the hierarchy is empty.
variant'plain' | 'bordered' | 'raised''plain'Sets the surrounding tree surface.
size'sm' | 'md' | 'lg''md'Controls row height, icon, and type scale.