Auto Layout
This example shows how you can automatically arrange nodes after adding items from a sidebar. This a common UI pattern for workflow editors and lets you create a flow quickly. The layout is calculated every time a node is added with the help of the d3-hierarchy (opens in a new tab) library. If you are subscribed to React Flow Pro (opens in a new tab), you will get access to two versions of this example: One using d3-hierarchy (opens in a new tab) and the other one using dagre.js (opens in a new tab) as a layout engine.
Dependencies: reactflow (opens in a new tab), d3-hierarchy (opens in a new tab) or dagre (opens in a new tab)
This is a Pro example. You can access the annotated source code if you are subscribed to React Flow Pro.