The Blazor TreeView is a UI component that displays hierarchical data, such as a table of contents, code examples, and file directories, in a tree structure. TreeView is feature-rich, supporting data binding, loading on demand, multiple selection, drag and drop, node editing, checkboxes, templates, and more in both Blazor WebAssembly (WASM) and Blazor Server apps.
TreeView loads data either from local data sources or remote data services using the DataSource property. This property supports the list of object arrays and DataManager. It also supports different kinds of data services such as OData, OData V4, Web API, URL, and JSON with the help of DataManager adaptors.
The load-on-demand feature loads huge amounts of data dynamically, which improves the component’s performance. Child nodes in the component can be loaded from any web service or inserted dynamically.
Display nodes with labels and icons or images to present content in a more readable format. This is helpful in making a typical directory tree and file system.
Built-in support for check boxes allows users to select more than one item. The Blazor TreeView check boxes also have a tri-state mode that is applicable only for parent nodes. In this mode, the parent node will go into an indeterminate state when the child nodes are partially checked.
In Blazor TreeView, Nodes can be dragged and dropped at all levels of the same TreeView.
Tree nodes can be dragged and dropped from one parent node to another within the same level or different levels.
Extending the drop behavior allows users to drop tree nodes from one tree view to another tree view.
Drop tree nodes to any external container or component by extending the tree view node drop action.
TreeView allows users to select multiple nodes. When the drag-and-drop feature is enabled, all the selected nodes can be dragged at the same time.
Edit the tree nodes’ label text on the client side by double-clicking it. While editing tree view nodes, the tree view data source will also be updated by the modified data.
Render the TreeView nodes in ascending or descending order based on the label text to provide users improved readability.
Customize the TreeView using the node template support to define a custom structure for tree nodes. You can use node templates for parent nodes, child nodes, or both, and include images and custom elements.
Easily customize the TreeView expand and collapse icons based on your application requirements.
It supports tooltips for tree nodes that display information about the nodes while hovering over them. You can bind a tooltip from a data source along with node fields.
A context menu can be integrated with the Blazor TreeView component to open when a node is right-clicked. The menu helps users perform node manipulations such as adding, removing, and renaming nodes.
A node’s text wraps when it reaches edge of the TreeView. The node’s height will be adjusted automatically based on the content.
It supports right-to-left (RTL) direction rendering for users working in right-to-left languages like Hebrew, Arabic, or Persian.
It allows you to customize the tree nodes by level. For example, apply specific styles to leaf nodes, first child nodes, and second level nodes, etc.
You can add validation to the tree node’s text on editing like required, a minimum or maximum length, etc.
Several built-in SASS-based themes are available such as Tailwind CSS, Bootstrap 5, Bootstrap 4, Bootstrap, Material, Fabric, and High Contrast. Simplify theme customization either by overriding the existing SASS styling or creating custom themes by using the Theme Studio application.
The Blazor TreeView component has a rich set of developer-friendly APIs to customize all UI elements and behaviors, allowing you to provide the best experience to your end users.
Easily get started with the Blazor TreeView using a few simple lines of C# code example as demonstrated below, Also explore our Blazor TreeView Example that shows you how to render the TreeView component in Blazor.
@using Syncfusion.Blazor.Navigations
<SfTreeView TValue="MailItem">
<TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MailItem
{
public string Id { get; set; }
public string ParentId { get; set; }
public string FolderName { get; set; }
public bool Expanded { get; set; }
public bool HasSubFolders { get; set; }
}
List<MailItem> MyFolder = new List<MailItem>();
protected override void OnInitialized()
{
base.OnInitialized();
MyFolder.Add(new MailItem
{
Id = "1",
FolderName = "Inbox",
HasSubFolders = true,
Expanded = true
});
MyFolder.Add(new MailItem
{
Id = "2",
ParentId = "1",
FolderName = "Categories",
Expanded = true,
HasSubFolders = true
});
MyFolder.Add(new MailItem
{
Id = "3",
ParentId = "2",
FolderName = "Primary"
});
MyFolder.Add(new MailItem
{
Id = "4",
ParentId = "2",
FolderName = "Social"
});
MyFolder.Add(new MailItem
{
Id = "5",
ParentId = "2",
FolderName = "Promotions"
});
}
}
TreeView is also available in JavaScript, Angular, React, and Vue frameworks that are built from their own TypeScript libraries. Check out the different TreeView platforms from the links below,
You can find our Blazor TreeView demo here.
No, this is a commercial product and requires a paid license. However, a free community license is also available for companies and individuals whose organizations have less than $1 million USD in annual gross revenue and five or fewer developers.
A good place to start would be our comprehensive getting started documentation.
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.