TreeItem

TreeItem(id, label, children=list(), *, caption='', disabled=False)

Represents a single item in a tree data structure.

Parameters

id : str

Unique identifier for the tree item. Must be unique across all items in the tree.

label : str

Display text for the tree item. Can include emoji and other characters.

caption : str = ''

Secondary text displayed below the label in smaller font.

children : list[TreeItem] = list()

List of child nodes.

disabled : bool = False

Whether the item is disabled (non-selectable).

Examples

Simple leaf item:

from shiny_treeview import TreeItem
leaf = TreeItem("doc1", "📄 Document.pdf")

Parent item with children:

folder = TreeItem(
    "documents",
    "📁 Documents",
    children=[
        TreeItem("doc1", "📄 Report.pdf"),
        TreeItem("doc2", "📄 Presentation.pptx", disabled=True)
    ]
)