diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md
index 1b666eba68..4ce17d312a 100644
--- a/COMPONENT_INDEX.md
+++ b/COMPONENT_INDEX.md
@@ -4707,9 +4707,10 @@ export interface TreeNode {
### Slots
-| Slot name | Default | Props | Fallback |
-| :-------- | :------ | :---- | :----------------------- |
-| labelText | No | -- | {labelText}
|
+| Slot name | Default | Props | Fallback |
+| :-------- | :------ | :-------------------------------------------------------------------------------------------------------------------------------- | :----------------------- |
+| -- | Yes | { node: { id: TreeNodeId; text: string; expanded: boolean, leaf: boolean; disabled: boolean; selected: boolean; } }
| {node.text}
|
+| labelText | No | -- | {labelText}
|
### Events
diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json
index dbc78008e9..d631b8eed6 100644
--- a/docs/src/COMPONENT_API.json
+++ b/docs/src/COMPONENT_API.json
@@ -14668,6 +14668,12 @@
],
"moduleExports": [],
"slots": [
+ {
+ "name": "__default__",
+ "default": true,
+ "fallback": "{node.text}",
+ "slot_props": "{ node: { id: TreeNodeId; text: string; expanded: boolean, leaf: boolean; disabled: boolean; selected: boolean; } }"
+ },
{
"name": "labelText",
"default": false,
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})
+
+
diff --git a/src/TreeView/TreeView.svelte b/src/TreeView/TreeView.svelte
index fa25b8a0f7..eabe6255de 100644
--- a/src/TreeView/TreeView.svelte
+++ b/src/TreeView/TreeView.svelte
@@ -2,6 +2,7 @@
/**
* @typedef {string | number} TreeNodeId
* @typedef {{ id: TreeNodeId; text: any; icon?: typeof import("svelte").SvelteComponent; disabled?: boolean; children?: TreeNode[]; }} TreeNode
+ * @slot {{ node: { id: TreeNodeId; text: string; expanded: boolean, leaf: boolean; disabled: boolean; selected: boolean; } }}
* @event {TreeNode & { expanded: boolean; leaf: boolean; }} select
* @event {TreeNode & { expanded: boolean; leaf: boolean; }} toggle
* @event {TreeNode & { expanded: boolean; leaf: boolean; }} focus
@@ -202,5 +203,9 @@
on:keydown
on:keydown|stopPropagation="{handleKeyDown}"
>
-
+
+
+ {node.text}
+
+
diff --git a/src/TreeView/TreeViewNode.svelte b/src/TreeView/TreeViewNode.svelte
index 33481b19e2..5e0aedd68d 100644
--- a/src/TreeView/TreeViewNode.svelte
+++ b/src/TreeView/TreeViewNode.svelte
@@ -34,6 +34,7 @@