Skip to content


A tree control to navigate the contents of your filesystem.

  • Focusable
  • Container


The example below creates a simple tree to navigate the current working directory.

from import App, ComposeResult
from textual.widgets import DirectoryTree

class DirectoryTreeApp(App):
    def compose(self) -> ComposeResult:
        yield DirectoryTree("./")

if __name__ == "__main__":
    app = DirectoryTreeApp()



The DirectoryTree.FileSelected message is sent when the user selects a file in the tree

  • Bubbles


attribute type purpose
path str Path of the file.

Reactive Attributes

Name Type Default Description
show_root bool True Show the root node.
show_guides bool True Show guide lines between levels.
guide_depth int 4 Amount of indentation between parent and child.

See Also

  • Tree code reference
  • Tree code reference