PR01 🎛️ Interactive Property Explorer
Experiment with different property combinations to see their effects
Live Tree Preview
Property Controls
Property Presets
Quick Presets:
PR02 🔧 Core Properties
Essential properties that define tree behavior and data structure
Property Details
| Property | Type | Default | Description |
|---|---|---|---|
data* | Array<object> | [] | Array of tree node objects. Each object must have properties specified by idMember, pathMember, and displayValueMember. |
idMember* | string | - | Property name that contains unique identifiers for each node. Must be unique across all nodes. |
pathMember* | string | - | Property name that contains the hierarchical path (e.g., "1", "1.1", "1.1.1") using LTree format. |
displayValueMember* | string | - | Property name that contains the text to display for each node. |
expandLevel | number | 2 | Initial expansion depth. Nodes at this level and above will be expanded by default. |
shouldToggleOnNodeClick | boolean | false | When true, clicking on a node will expand/collapse it instead of just selecting. |
Usage Examples
Implementation Notes
🏗️ Data Structure Requirements
- Unique IDs: Each node must have a unique identifier
- Path Hierarchy: Use dot notation like "1.2.3" for parent-child relationships
- Flat Array: All nodes in a single array, not nested objects
📊 Path Format Examples
"1"- Root level node"1.1"- Child of node "1""1.1.1"- Grandchild of node "1""2.5.3"- Third child of fifth child of second root
⚡ Performance Notes
The component efficiently handles large datasets using the LTree structure for fast hierarchy lookups.
PR03 🎨 Styling & Display Properties
Properties that control visual appearance and user interface elements
Styling Properties
| Property | Type | Default | Description |
|---|---|---|---|
shouldUseBootstrapIconClasses | boolean | true | Use Bootstrap's chevron-right/chevron-down for expand/collapse icons |
treeClass | string | "" | CSS class applied to the root tree container |
nodeClass | string | "" | CSS class applied to individual tree nodes |
selectedNodeClass | string | "" | CSS class applied to selected nodes |
expandedNodeClass | string | "" | CSS class applied to expanded parent nodes |
dragHighlightClass | string | "" | CSS class applied during drag operations for visual feedback |
Styling Examples
CSS Integration
🎯 Bootstrap Integration
Works seamlessly with Bootstrap classes out of the box. Set shouldUseBootstrapIconClasses to false for custom icon solutions.
🖌️ Custom Themes
Use the various class properties to implement custom themes, dark modes, or brand-specific styling.
✨ State Classes
Different classes for selected, expanded, and drag states allow for rich visual feedback and smooth animations.
📱 Responsive Design
All styling properties work with responsive design patterns and CSS frameworks.
PR04 🔄 Interaction Properties
Properties that control drag & drop, search, and user interactions
Interaction Properties
| Property | Type | Default | Description |
|---|---|---|---|
isDragAndDropEnabled | boolean | false | Enable drag and drop functionality for reordering nodes |
dragValidationCallback | function | null | Function to validate drag operations: (draggedNode, targetNode, position) => boolean |
searchText | string | "" | Search query string that filters and highlights matching nodes |
getSearchValueCallback | function | null | Custom function to extract searchable text from nodes: (node) => string |
sortCallback | function | null | Custom sorting function for tree nodes: (items) => sortedItems |
shouldSelectOnClick | boolean | true | Whether clicking a node should select it |
dragDropMode | string | 'both' | Controls drag-drop operations: 'none' | 'self' | 'cross' | 'both'. 'self' = same tree only, 'cross' = between trees only |
orderMember | string | null | Property name containing sort order value for sibling ordering (e.g., "sortOrder") |
dragOverNodeClass | string | "" | CSS class for drag-over visual feedback. Built-in: 'ltree-dragover-highlight', 'ltree-dragover-glow' |
Advanced Usage
Interaction Guide
🤏 Drag & Drop Validation
Use dragValidationCallback to implement business rules like preventing files from being dropped into other files or checking permissions.
🔍 Flexible Search
The search system uses FlexSearch for performance. Customize what's searchable with getSearchValueCallback.
📊 Dynamic Sorting
Sort callbacks receive tree nodes with access to original data via node.data. Useful for sorting by dates, types, or custom criteria.
⚡ Performance Tips
Validation and search callbacks are called frequently - keep them lightweight and avoid expensive operations.
PR05 🎯 Drop Zone Properties (v4.5.0+)
Configure visual drop indicators and positioning for drag-drop operations
Drop Zone Properties
| Property | Type | Default | Description |
|---|---|---|---|
dropZoneLayout | string | 'around' | Drop zone arrangement: 'around' | 'above' | 'below' | 'wave' | 'wave2' |
dropZoneStart | number | string | 33 | Horizontal start position (number = %, string = CSS value like "50px") |
dropZoneMaxWidth | number | 120 | Maximum width in pixels for wave layouts |
isLoading | boolean | false | Shows a loading overlay on the tree during async operations |
Drop Zone Layouts
'around'- Above zone on top, Below/Child zones on bottom (default)'above'- All 3 zones in a horizontal row above the node'below'- All 3 zones in a horizontal row below the node'wave'- Zones stacked vertically with fixed width'wave2'- Diagonal wave pattern with offset
Usage Examples
Configuration Guide
🎯 Drop Positions
When dropping a node, the position parameter indicates:
'above'- Insert as sibling before target'below'- Insert as sibling after target'child'- Insert as child of target
📱 Touch Support
Touch drag-drop is enabled by default:
- Long-press (300ms) initiates drag
- Ghost element follows finger
- Haptic feedback on drag start
⏳ Loading State
Use isLoading to show a visual overlay during async operations like database saves.
📦 Empty Tree Drops
Use the dropPlaceholder snippet to show a drop zone in empty trees.
📝 Callback Properties (Svelte 5)
Event callbacks using Svelte 5 prop syntax instead of on:event dispatchers
Callback Properties
| Property | Signature | Description |
|---|---|---|
onNodeClicked | (node: LTreeNode) => void | Called when a node is clicked |
onNodeDragStart | (node, event) => void | Called when drag operation begins |
onNodeDrop | (dropNode, draggedNode, position, event) => void | Called when node is dropped. position is 'above'|'below'|'child'. dropNode can be null. |
contextMenuCallback | (node, closeMenu) => ContextMenuItem[] | Returns context menu items for a node |
onNodeClicked={handler} not on:nodeClick={handler}.Usage Examples
Migration Guide
🔄 Svelte 4 → Svelte 5 Migration
| Svelte 4 | Svelte 5 |
|---|---|
on:nodeClick | onNodeClicked |
on:drop | onNodeDrop |
on:dragStart | onNodeDragStart |
⚠️ Breaking Change: onNodeDrop
The drop callback now includes position and operation parameters:
- Before:
(dropNode, draggedNode, event) - After:
(dropNode, draggedNode, position, event, operation)
🎯 Null dropNode
dropNode is null when dropping:
- Into an empty tree (via dropPlaceholder)
- Into the root drop zone