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.

Namespace
Tesserae
Inheritance
ComponentBase<Tree, HTMLUListElement> → Tree
Implements
IContainer<Tree.Item, Tree.Item>

Constructors

NameDescription
TreeInitializes a new instance of this class.
Constructor
Tree
public Tree()

Initializes a new instance of this class.

Properties

NameDescription
SelectedItemGets the currently selected item.
Property
Tree.SelectedItem
public Item SelectedItem { get; private set; }

Gets the currently selected item.

Methods

NameDescription
RenderRenders the component's root HTML element.
OnSelectedRegisters a callback invoked when the selected event fires.
SelectionEnabledEnables or disables item selection on the tree.
AddAdds the given item to the component.
ClearClears the component's current state.
ReplaceReplaces an existing item with a new one.
ItemsAdds the given items to the component.
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

NameDescription
SelectedItemChangedRaised when selected item changed occurs.
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 Curiosity. All rights reserved.