Live Demo
View the live demo on vueflow.dev.Complete Example
Key Concepts
Parent-Child Relationships
Create nested nodes by setting theparentNode property:
Child node positions are relative to the parent node’s position, not absolute.
Multi-Level Nesting
You can nest nodes multiple levels deep:Node Extent
Control how child nodes can be positioned:- Parent Extent
- With Padding
- Custom Bounds
Constrain child node within parent boundaries:
Expand Parent
Automatically expand parent nodes to fit children:Styling Parent Nodes
Size Parent Nodes
Parent nodes need explicit dimensions:Visual Hierarchy
Create visual distinction between parent and child nodes:Connection Mode
For nested flows, useConnectionMode.Loose to allow connections between nodes at different nesting levels:
ConnectionMode.Strict: Only connect to visible handlesConnectionMode.Loose: Connect to any node (recommended for nested flows)
Dynamic Nesting
Add Child Nodes Dynamically
Change Parent
Remove from Parent
Working with Nested Nodes
Get All Children
Get All Descendants
Get Parent Chain
Interaction Behaviors
Drag Parent with Children
By default, dragging a parent node moves all its children. To prevent this:Select Parent and Children
Performance Considerations
- Deeply nested structures (>3 levels) may impact performance
- Consider using virtual rendering for large nested hierarchies
- Use
expandParentsparingly to avoid layout recalculations - Cache parent-child relationships for frequent lookups
Use Cases
- Grouping: Group related nodes together
- Swimlanes: Create workflow lanes
- Hierarchies: Represent organizational structures
- Containers: Create collapsible sections
- Subflows: Nest entire flows within nodes
Example: Collapsible Parent
TypeScript Support
Best Practices
- Always set explicit dimensions on parent nodes
- Use
extent: 'parent'to keep children within boundaries - Position children relative to parent (0,0 is top-left of parent)
- Use
ConnectionMode.Loosefor nested flows - Provide visual feedback for parent-child relationships
Next Steps
Custom Nodes
Create custom parent node components
Layouting
Auto-layout nested structures
Node API
Complete node type reference
State Management
Managing complex nested state