Tesserae

Tree

Description

A component that displays a hierarchical list

A tree displays hierarchical data. Nodes can be expanded or collapsed to reveal nested data.

Supports synchronous and asynchronous loading of child nodes.

API reference

class

Tree

public sealed class Tree : ComponentBase<Tree, HTMLUListElement>, IContainer<Tree.Item, Tree.Item>

A vertically-stacked tree view with expand / collapse, keyboard navigation, selection and arbitrary item rendering.

Constructors

Constructor
Tree
public Tree()

Initializes a new instance of this class.

Properties

Property
Tree.SelectedItem
public Item SelectedItem { get; private set; }

Gets the currently selected item.

Methods

Method
Tree.Render
public override HTMLElement Render()

Renders the component's root HTML element.

Method
Tree.OnSelected
public Tree OnSelected(ComponentEventHandler<Tree, Item> onSelected)

Registers a callback invoked when the selected event fires.

Method
Tree.SelectionEnabled
public Tree SelectionEnabled(bool enabled = true)

Enables or disables item selection on the tree.

Method
Tree.Add
public void Add(Item component)

Adds the given item to the component.

Method
Tree.Clear
public void Clear()

Clears the component's current state.

Method
Tree.Replace
public void Replace(Item newComponent, Item oldComponent)

Replaces an existing item with a new one.

Method
Tree.Items
public Tree Items(params Item[] children)

Adds the given items to the component.

Events

Event
Tree.SelectedItemChanged
public event ComponentEventHandler<Tree, Item> SelectedItemChanged

Raised when selected item changed occurs.

Samples

Basic Synchronous Tree

Asynchronous Tree

Selectable Tree

File-System Tree with Selection Events

This sample models a realistic project layout. OnSelected on the Tree fires every time the user clicks an item, so we mirror the path of the selected node in a panel beside the tree.

See also

© 2026 Tesserae. All rights reserved.