packages/docs/src/pages/en/components/treeview.md
The v-treeview component is useful for displaying large amounts of nested data.
A basic example of the treeview component.
<ExamplesExample file="v-treeview/usage" /> <PromotedEntry />| Component | Description |
|---|---|
| v-treeview | Primary Component |
| v-treeview-item | Sub-component used to display a single treeview node |
| v-treeview-group | Sub-component used to display a single treeview node's children |
::: info
There is a bug related to how babel-plugin-jsx renders templates that degrades VTreeview performance. We are tracking the issue here.
:::
The v-treeview component is useful for displaying large amounts of nested data. It is a tree structure that can be expanded and collapsed, allowing users to navigate through the hierarchy of items.
It is built on top of the v-list component, which provides the basic structure and functionality for displaying lists of items. The v-treeview component extends this functionality by adding support for hierarchical data, allowing users to expand and collapse items to reveal or hide their children.
The v-treeview component has several props that allow you to customize its appearance and behavior.
Treeview nodes can be activated by clicking on them.
<ExamplesExample file="v-treeview/prop-activatable" />You can control the text and background color of the active treeview node.
<ExamplesExample file="v-treeview/prop-color" />Dense mode provides more compact layout with decreased heights of the items.
<ExamplesExample file="v-treeview/prop-dense" />When working with large trees it is recommended to include items-registration="props" to ensure faster loading and interactions.
If item-props is set to true then the whole item will be spread. In the following example, the disabled prop defined in each item will disable the item accordingly.
Treeview nodes can be pre-opened on page load.
<ExamplesExample file="v-treeview/prop-open-all" /> <!-- #### Rounded You can make treeview nodes rounded. <ExamplesExample file="v-treeview/prop-rounded" /> -->The fluid prop removes the extra indentation used to line up children. This is useful when you want to reduce the horizontal space used by the treeview.
<ExamplesExample file="v-treeview/prop-fluid" />You can control the color of the selected node checkbox.
<ExamplesExample file="v-treeview/prop-selected-color" />Treeview supports several selection modes:
Classic has two variants that are displayed the same way but with slightly different v-model behavior:
You can dynamically load child data by supplying a Promise callback to the load-children prop. This callback will be executed the first time a user tries to expand an item that has a children property that is an empty array.
<ExamplesExample file="v-treeview/prop-load-children" />The v-treeview component has several slots that allow you to customize the appearance and behavior of its items.
Using the the prepend slot we are able to create an intuitive file explorer.
<ExamplesExample file="v-treeview/slot-append-and-label" />Both append, and prepend slots get additional information about the item: depth, path (from indexes), isFirst, isLast and the index within the children list.
When searching within the treeview, you might want to show custom no-data slot to provide context or immediate action.
<ExamplesExample file="v-treeview/slot-no-data" />In this example we use a custom title slot to apply a line-through the treeview item's text when selected.
<ExamplesExample file="v-treeview/slot-title" />Here, a custom toggle slot is utilized to assign a specific color and variant to the button depending on the state of the item.
<ExamplesExample file="v-treeview/slot-toggle" />The footer slot renders below a group's children nodes. Here it adds a "Load more" row per group that shows a loading trigger and indicator while the data is being fetched.
<ExamplesExample file="v-treeview/slot-footer" />The following are a collection of examples that demonstrate more advanced and real world use of the v-treeview component.
Easily filter your treeview by using the search prop. You can easily apply your custom filtering function if you need case-sensitive or fuzzy filtering by setting the custom-filter prop. This works similar to the v-autocomplete component.
<ExamplesExample file="v-treeview/misc-search-and-filter" />Customize the on, off and indeterminate icons for your selectable tree. Combine with other advanced functionality like API loaded items.
<ExamplesExample file="v-treeview/misc-selectable-icons" />The v-treeview component can be configured to show indent lines. The indent-lines prop controls lines visibility and the variant.