> For the complete documentation index, see [llms.txt](https://voit.gitbook.io/voitdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://voit.gitbook.io/voitdocs/components/list-tree.md).

# List Tree

Tree views provide a hierarchical structure for displaying nested items, such as files and folders. They allow users to expand and collapse nodes to navigate through different levels of content.

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FI8kW1BmtIuKNFNXiM7j7%2FFrame%2045.png?alt=media&amp;token=10d63339-6384-42a7-934d-4aeab512915b" alt=""><figcaption></figcaption></figure>

## Overview

Tree views allow users to explore and interact with deeply nested content dynamically, offering flexibility in how data is presented and navigated.

{% embed url="<https://www.figma.com/design/4NwKhd4dwRhRF5Zpiooi69/Components?node-id=2-262760&t=0Thv0LIO2gFzE3eo-4>" %}

## When to use

* Use tree views to display nested, structured data that requires user interaction to explore its various levels.&#x20;
* Use a tree view when information is categorized into multiple layers or subcategories, allowing users to explore data progressively.&#x20;
* Tree views are effective when handling vast amounts of data that would be overwhelming to display in a flat list or grid view.

## When not to use

* Avoid using a tree view if the content isn’t arranged hierarchically. Use a simple list view for flat data sets.&#x20;
* If the content structure is simple with only one level, a list view or card component might be a better option.&#x20;
* If you're building a menu for simple category navigation (without nested levels), a navigation menu or tab component is more appropriate.&#x20;
* Tree view might seem similar in allowing content expansion with accordions, but accordions are used to display sections of content, not nested items like tree views.

## Types

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2Fu5QUweCf7LV3glkRRLIA%2Fvariants.png?alt=media&amp;token=42c0e80c-07d4-4c12-974d-437e7db859bb" alt=""><figcaption></figcaption></figure>

## Anatomy

1. **Check Box:** Allows the user to select or deselect the item.&#x20;
2. **Leading Content:** A visual element on the left side of the tree item. (Chevron, Icon, Checkbox, Switch, etc.)&#x20;
3. **Text (Title):** The primary label for each item in the tree view, representing the core content or category.&#x20;
4. **Helper:** An optional element providing additional information or context for the item.&#x20;
5. **Trailing Content:** An optional visual element representing status or interaction options on the right side. (Shortcut, Icon, Chevron, etc.)&#x20;
6. **Slot:** A placeholder element that can be swapped with other components.&#x20;
7. **Switch:** A toggle element enabling on/off states for the item.&#x20;
8. **Description:** A brief summary or explanation of the tree item, giving further detail if necessary.&#x20;
9. **Container:** The structural component that holds all the tree view items, ensuring alignment, spacing, and visual grouping.

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FVqgqtgUSD78dbL80TbUA%2FAnatomy.png?alt=media&amp;token=a70c118e-7367-4f1b-8b45-b0ba5521ffd0" alt=""><figcaption></figcaption></figure>

## Styles

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FDPsZPhydD6Fi1gxwaA2s%2FStyle.png?alt=media&amp;token=f3ad2a88-3f57-43d7-95ea-cd6340e4756d" alt=""><figcaption></figcaption></figure>

## States

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FPtfNqzP05eXW4XckQsOP%2FState.png?alt=media&amp;token=04021aa7-fd10-43f4-998c-f611908236e4" alt=""><figcaption></figcaption></figure>

## Size

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FTL9q1gzZXYw97xOxdfUa%2FSize.png?alt=media&amp;token=5ce10f90-c3c3-46db-8ffd-73b2a6df57ce" alt=""><figcaption></figcaption></figure>

| Size   | Text (px) | Description (px) | Icon (px) | Corner (px) | Container Height (px) |
| ------ | --------- | ---------------- | --------- | ----------- | --------------------- |
| Small  | 14        | 12               | 16        | 8           | 37                    |
| Medium | 16        | 12               | 20        | 8           | 44                    |
| Large  | 18        | 14               | 20        | 8           | 45                    |

## Accessibility

* **Keyboard Navigation:** Ensure tree views are fully accessible using a keyboard, allowing users to expand, collapse, and navigate through nodes with arrow keys.&#x20;
* **Screen Reader Support:** Tree views should provide clear labels and roles for screen readers, ensuring that hierarchical levels and node states (expanded/collapsed) are communicated effectively.&#x20;
* **Focus Management:** Proper focus management is essential, especially when expanding or collapsing nodes, to avoid disorienting users who rely on assistive technology.&#x20;
* **Clear Visual Cues:** Use clear indicators like arrows or chevrons to signal expandable and collapsible nodes, improving usability for all users.

## Example

* **File Explorer:** Display a hierarchical file system where users can expand folders to view subfolders and files.&#x20;
* **Category Management:** In an e-commerce application, allow users to navigate product categories, expanding subcategories as needed.&#x20;
* **Organizational Chart:** Visualize and navigate the structure of a company, allowing users to expand and collapse departments and teams.&#x20;
* **Documentation Navigation:** Present a multi-level documentation index, enabling users to collapse sections they don’t need.&#x20;
* **Navigation Sidebar in a Web Application:** Organize different sections such as Dashboard, Profile, and Settings in a collapsible list, with chevrons indicating expandable groups.
