diff --git a/docs/src/pages/components/TreeView.svx b/docs/src/pages/components/TreeView.svx index fe2a4aa0a6..112941793f 100644 --- a/docs/src/pages/components/TreeView.svx +++ b/docs/src/pages/components/TreeView.svx @@ -1,5 +1,5 @@ @@ -17,6 +17,23 @@ A parent node contains `children` while a leaf node does not. +## Slottable node + +By default, each item renders the value of `node.text`. Use the data from `let:node` directive to override the default slot. + +The destructured `let:node` contains the following properties: + + + id: the node id + text: the node text + expanded: true if the node is expanded + leaf: true if the node does not have children + disabled: true if the node is disabled + selected: true if the node is selected + + + + ## Initial active node The active node can be set through `activeId`. diff --git a/docs/src/pages/framed/TreeView/TreeViewSlot.svelte b/docs/src/pages/framed/TreeView/TreeViewSlot.svelte new file mode 100644 index 0000000000..e608e54556 --- /dev/null +++ b/docs/src/pages/framed/TreeView/TreeViewSlot.svelte @@ -0,0 +1,61 @@ + + + + + {node.text} (id: {node.id}) + +