类型 Tree

API 文档由 Go 源码生成,内容为英文。

type Tree struct {
	// contains filtered or unexported fields
}

Tree paints a compact vertical hierarchy. Applications own the hierarchy, expansion, selection, and scrolling; the component owns indentation, disclosure geometry, focus/hover feedback, and typed hit semantics.

构造函数

BeginTree#

func BeginTree(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect) Tree

BeginTree starts a tree declaration. Keep item IDs and flattened order stable between paints so retained commands, hover, and focus remain stable.

shadcn has no tree; the reference is the file tree of AI Elements, whose rows are small ghost buttons (one control tall) and whose children are indented 16px (ml-4). RowHeight and Indent override both.

方法

Indent#

func (tree Tree) Indent(width float32) Tree

Indent changes the offset applied for each hierarchy depth.

Item#

func (tree *Tree) Item(item TreeItem) TreeRow

Item paints one visible row and returns its caller-owned content area. The component never walks children or allocates a backing model.

RowHeight#

func (tree Tree) RowHeight(height float32) Tree

RowHeight changes the height of subsequent rows.