Tree
PROExpand and explore a hierarchy, then select or edit items.
Usage guide
#Use to explore and manage hierarchical data, such as files or organizations. Use Tree Select to collect a value in a form.
Build the tree
Provide unique
valueidentifiers,label, andchildreninnodes.Set the interaction scope
Enable
expandable,clickable, orcheckable, and further restrict interactions on individual nodes.Save changes
Handle
nodesChangedand save in your app. Example changes affect only the local view.
Examples
#Feature examples
#Choose a feature from 22 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.
<sy-tree>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
TreeNode[] | [] | Array of tree nodes with label, value, and children. Pass objects and arrays as JavaScript properties. | |
boolean | false | Select multiple items using checkboxes. | |
boolean | false | Allow user selection and emit the selected event. | |
boolean | false | Allow nodes to be moved by dragging. | |
boolean | false | Allow node names to be edited. | |
boolean | false | Allow tree branches to be expanded and collapsed. | |
boolean | false | Expand all tree branches initially. | |
boolean | false | Have the app call manualAddChildNode after an add request. | |
boolean | false | Have the app call manualRemoveNode after a removal request. | |
boolean | false | Show connectors between parent and child nodes. | |
number | null | null | Display width of tree nodes. | |
string | '' | Unique key of the selected node. | |
string | '' | Search query used to filter and highlight candidates. | |
boolean | false | Used internally with Tree Select. Keep the default for a regular Select. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<TreeNodesChangedDetail> | Read the result from the event's detail. | |
CustomEvent<TreeItemCheckedDetail> | Read the result from the event's detail. | |
CustomEvent<TreeItemSelectedDetail> | Read the result from the event's detail. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Change the checked state of the specified tree node. | |
Promise<void> | Clear all checked tree selections. | |
Promise<void> | Add a new child under a parent node. | |
Promise<void> | Remove a tree node by its unique key. | |
Promise<TreeNode | null> | Find the node matching a unique key in the supplied node array. |
<sy-tree-item>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Show the add-child action. | |
boolean | false | Select multiple items using checkboxes. | |
boolean | false | Selected or on state. | |
boolean | false | Allow user selection and emit the selected event. | |
boolean | false | Block user interaction and keyboard focus. | |
boolean | false | Allow this node to be dragged. | |
boolean | false | Whether the node is being dragged. Managed by the parent. | |
'none' | 'valid' | 'invalid' | 'none' | Indicate whether dropping is allowed. Managed by the parent. | |
boolean | false | Allow name editing. | |
boolean | false | Allow tree branches to be expanded and collapsed. | |
boolean | false | Whether children are expanded. | |
boolean | false | Restrict node movement. | |
boolean | false | Indicate whether child nodes exist. | |
string | 'New item' | Placeholder for the new node name input. | |
string | '' | Set icon visibility or icon content. Check the format supported by each component. | |
boolean | false | Indeterminate state when only some items are selected. | |
boolean | false | Whether the node is nested under another node. Managed by the parent. | |
boolean | false | Indicate whether the name is being edited. | |
string | '' | Label describing the item. | |
number | 0 | Hierarchy depth. Managed by the parent. | |
boolean | false | Allow the node removal action. | |
any[] | [] | Child node array, passed down by the parent. Pass objects and arrays as JavaScript properties. | |
string | '' | Tag text beside the node. | |
"gray" | "purple" | "blue" | "green" | "cyan" | "yellow" | "orange" | "red" | undefined | undefined | Tag color beside the node. | |
string | '' | Current value or item identifier. | |
string | '' | Search query used to filter and highlight candidates. | |
string | '' | Unique key of the currently selected node. | |
number | null | null | Display width of tree nodes. | |
boolean | false | Show connectors between parent and child nodes. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<{ value: string; label: string; expanded: boolean }> | Read the result from the event's detail. | |
CustomEvent<{ value: string; label: string; checked: boolean }> | Read the result from the event's detail. | |
CustomEvent<{ parentValue: string; childLabel: string; childValue: string; childLevel: number }> | Read the result from the event's detail. | |
CustomEvent<{ value: string; label: string }> | Read the result from the event's detail. | |
CustomEvent<{ value: string; label: string }> | Read the result from the event's detail. | |
CustomEvent<any> | Read the result from the event's detail. | |
CustomEvent<any> | Read the result from the event's detail. | |
CustomEvent<{ targetKey: string; draggedKey: string; dropPosition: string; targetLevel: number }> | Read the result from the event's detail. | |
CustomEvent<{ value: string; label: string; checked: boolean }> | Read the result from the event's detail. | |
CustomEvent<string> | Read the result from the event's detail. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Layout only, and called fire-and-forget by the parent tree, so it never rejects: a no-op before the item started, and it still runs while frozen. |