# Auto-layout

Auto-layout can automatically organize your nodes to minimize edge crossings and optimize spacing between nodes. Here's how to use it:

## Option 1: Enable during data loading

In your [Load nodes and edges](/reactflow-for-bubble.io/element-reference/actions/load-nodes-and-edges.md) action, enable **"Enable auto layout"**. This will automatically position nodes when they are loaded into the chart.

## Option 2: Apply layout to existing diagrams

Use the [**Auto layout**](/reactflow-for-bubble.io/element-reference/actions/auto-layout.md) action in your workflows. Trigger it with a button click or any event to instantly reorganize existing nodes into a clean layout.

## Configuration settings (for both options)

Both methods use the configuration from your ReactFlow element properties in the **"Auto layout"** section:

* [**Layout direction**](/reactflow-for-bubble.io/element-reference/fields.md#layout-direction) - Choose TB (top-to-bottom), BT (bottom-to-top), LR (left-to-right), or RL (right-to-left)
* [**Node width for layout**](/reactflow-for-bubble.io/element-reference/fields.md#node-width-for-layout) and [**Node height for layout**](/reactflow-for-bubble.io/element-reference/fields.md#node-height-for-layout) - Node size in pixels for layout calculations

The auto-layout uses the industry-standard Dagre algorithm.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enhancio.gitbook.io/reactflow-for-bubble.io/guides/auto-layout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
