Member-only story
Vuetify — Treeview Search and Open
3 min readJan 4, 2021
Vuetify is a popular UI framework for Vue apps.
In this article, we’ll look at how to work with the Vuetify framework.
Open-All
Treeview nodes can be pre-opened on page load.
To do that, we can add the open-all
prop to the v-treeview
component:
<template>
<v-treeview open-all :items="items"></v-treeview>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
items: [
{
id: 1,
name: "Root",
children: [
{ id: 2, name: "Child 1" },
{ id: 3, name: "Child 2" },
{
id: 4,
name: "Child 3",
children: [
{ id: 5, name: "Grandchild 1" },
{ id: 6, name: "Grandchild 2" },
],
},
],
},
],
}),
};
</script>
It’ll expand all the nodes when we load the page.
Treeview Slots
Treeviews have various slots.
The prepend
slot lets us add content to the left of the node.
The label
has the label for the node.
And the append
slot lets us add content to the right of the label.