Tree

A hierarchical list structure component. Almost anything can be represented in a tree structure.

When To Use

  • Almost anything can be represented in a tree structure. Examples include directory systems, organization charts, biology classifications, countries, etc.

Basic

  • parent 1
    • parent 1-0
      • leaf
      • leaf
    • parent 1-1

Checkable

Add the checkable prop to both the Tree component and each TreeNode to enable checkboxes. Parent/child checkbox logic (indeterminate state) is handled automatically.

  • parent 1
    • parent 1-0
      • leaf
      • leaf
    • parent 1-1

Custom Icons

You can add custom icons to tree nodes, which is very useful for file system representations.

  • src
    • components
      • Tree.astro
      • TreeNode.astro
    • pages
  • package.json
  • README.md

API Reference

Tree

Property
Description
Type
Default

checkable

Enables checkboxes for the entire tree boolean false

TreeNode

Property
Description
Type
Default

title

Tree string '-'

checkable

Renders a checkbox for this specific node boolean false

expanded

Whether the node is expanded by default boolean false

icon

Optional IconName to display before the title IconName '-'