npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

virtual-tree-list-plus

v1.1.5

Published

A high-performance virtual scrolling tree list component written in TypeScript

Readme

virtual-tree-list-plus

高性能原生 TypeScript 虚拟滚动树形组件,无框架依赖,支持海量树数据渲染,开箱即用。

npm version install size

✨ 特性

  • 🚀 虚拟列表:仅渲染可视区域节点,万级/十万级树数据流畅滚动不卡顿
  • 🌳 无限层级树形:支持节点展开/收起、层级缩进
  • 📘 完整 TypeScript 类型,IDE 友好提示
  • 🧩 原生实现:不依赖 Vue / React,任意前端项目通用
  • 📦 多格式输出:ESM / CJS / UMD,支持浏览器、Node、构建工具
  • 🪶 零依赖:体积轻量,无第三方库
  • 🎨 基础样式简洁,可自定义覆盖

适用场景

  • 后台管理系统组织架构树
  • 权限菜单树、部门树
  • 海量数据树形选择器
  • 树形表格、文件目录树
  • 万级节点高性能渲染场景

📦 安装

npm install virtual-tree-list-plus
# or
yarn add virtual-tree-list-plus
# or
pnpm add virtual-tree-list-plus
🚀 快速上手
```html
import { VirtualTreeListPlus } from 'virtual-tree-list-plus'
import type { TreeNode } from 'virtual-tree-list-plus'

// 树形数据源
const treeData: TreeNode[] = [
  {
    id: 1,
    label: '一级节点 1',
    children: [
      { id: 11, label: '二级节点 1-1' },
      {
        id: 12,
        label: '二级节点 1-2',
        children: [{ id: 121, label: '三级节点 1-2-1' }]
      }
    ]
  },
  { id: 2, label: '一级节点 2' }
]

// 挂载容器
const container = document.getElementById('tree-container')!

// 初始化虚拟树
new VirtualTreeListPlus({
  container,
  data: treeData,
  itemHeight: 40,
  defaultExpandAll: false
})

原生 HTML / UMD 直接引入

<div id="tree-container" style="width:400px;height:500px;border:1px solid #ccc;"></div>

<script src="https://unpkg.com/virtual-tree-list-plus/dist/virtual-tree-list-plus.umd.js"></script>
<script>
  const { VirtualTreeListPlus } = window.VirtualTreeListPlus

  const data = [
    { id: 1, label: '根节点', children: [{ id: 11, label: '子节点' }] }
  ]

  new VirtualTreeListPlus({
    container: document.getElementById('tree-container'),
    data,
    itemHeight: 40
  })
</script>

📖 类型定义

interface TreeNode {
  id: string | number
  label: string
  children?: TreeNode[]
  [key: string]: any // 支持自定义扩展字段
}

VirtualTreeOptions 配置项

interface VirtualTreeOptions {
  /** 挂载容器 DOM 元素 */
  container: HTMLElement
  /** 树形数据源 */
  data: TreeNode[]
  /** 每个节点固定高度(px),必填 */
  itemHeight: number
  /** 默认是否展开所有节点,默认 false */
  defaultExpandAll?: boolean
}

🔧 实例方法

const tree = new VirtualTreeListPlus({ ... })

// 更新树数据,重新渲染
tree.updateData(newData: TreeNode[])

// 销毁实例,清空容器、移除滚动监听
tree.destroy()