Tree.js

Download Back To CSSScript.Com

A lightweight, flexible, and zero-dependency tree widget for the modern web. Compatible with Vanilla JS, React, and Vue.

Basic Usage

Initialize the tree with a simple JSON structure. Default configuration handles hierarchical rendering automatically.

Configuration

Initialized with static JSON data. closeDepth is set to 3 to expand nodes by default.

Selection & Events

Robust selection support with checkboxes. Listen to onChange events to trigger actions.

Event Log

--:--:--Ready

Try checking and unchecking boxes. The tree supports tri-state checkboxes (checked, unchecked, indeterminate) automatically.

Async Data Loading

Simulate fetching data from a remote server. The tree renders seamlessly once data is provided.

Actions

Click to simulate a 1.5s network request.

API Control

Control the tree programmatically using the exposed API methods.

Methods

Selection API