Skip to content

treeview add

A tree view renders hierarchical data inside a menu’s container, driven by getChildren / getTreeItem.

Terminal window
vsceasy treeview add --name files --menu settings --title "Files"

Flags

FlagTypeNotes
--nametextRequired. Tree view id.
--menumenu idRequired. Container to render inside.
--titletextView title.

What it generates

src/treeViews/<name>.ts with a getChildren you fill in with real data.

src/treeViews/files.ts
import { defineTreeView, TreeNode } from '../shared/vsceasy';
export default defineTreeView({
title: 'Files',
menu: 'settings',
getChildren: async (parent, vscode, ctx) => {
if (!parent) {
return [
{ label: 'Item 1', icon: 'file', tooltip: 'Replace with real data' },
{ label: 'Group', icon: 'folder', collapsed: 'collapsed', children: [] },
] as TreeNode[];
}
// Lazy children — return based on parent.id / parent.contextValue.
return [];
},
});

A TreeNode may carry a panel or command to run on click, plus icon, tooltip, collapsed, and contextValue for when-clause targeting.