Grid, circular, and layered layouts

Arrange nodes with Grid, Circular, and Dagre

Choose a layout

TypeDescriptionExample configuration
gridArrange nodes in two rows and three columns.{ type: 'grid', rows: 2, cols: 3 }
circularArrange nodes in a ring with radius 100.{ type: 'circular', radius: 100 }
dagreArrange dependency layers from left to right.{ type: 'dagre', rankdir: 'LR' }

Compare layouts

Use Layout to switch between grid, circular, and dagre on the same graph. The code shows the full configuration for all three.

Loading example…
Use Layout to compare grid, circular, and layered arrangements of the same graph.
const layouts: Record<string, LayoutConfig> = {
  grid: { type: 'grid', rows: 2, cols: 3, width: 360, height: 160 },
  circular: { type: 'circular', radius: 100 },
  dagre: { type: 'dagre', rankdir: 'LR', nodesep: 64, ranksep: 96, nodeSize: 28 },
};

Adjust layer spacing

In Dagre, nodesep sets the spacing within a layer, and ranksep sets the spacing between layers. Set rankdir to LR for left to right or TB for top to bottom.

See the layout reference for more parameters, or try the flowchart example.