Drupal is a registered trademark of Dries Buytaert
Drupal 11.4.2 Update released for Drupal core (11.4.2)! Drupal 11.4.1 Update released for Drupal core (11.4.1)! Drupal 11.4.0 Update released for Drupal core (11.4.0)! Drupal 10.6.12 Update released for Drupal core (10.6.12)! Drupal 11.3.13 Update released for Drupal core (11.3.13)! Drupal 10.6.11 Update released for Drupal core (10.6.11)! Drupal 11.3.12 Update released for Drupal core (11.3.12)! Drupal 11.2.14 Update released for Drupal core (11.2.14)! Drupal 10.5.12 Update released for Drupal core (10.5.12)! Cms 2.1.3 Update released for Drupal core (2.1.3)! Drupal 10.5.11 Update released for Drupal core (10.5.11)! Drupal 11.3.11 Update released for Drupal core (11.3.11)! Drupal 11.2.13 Update released for Drupal core (11.2.13)! Drupal 10.6.10 Update released for Drupal core (10.6.10)! Cms 2.1.2 Update released for Drupal core (2.1.2)! Drupal 11.1.10 Update released for Drupal core (11.1.10)! Drupal 10.5.10 Update released for Drupal core (10.5.10)! Drupal 10.4.10 Update released for Drupal core (10.4.10)! Drupal 11.2.12 Update released for Drupal core (11.2.12)! Drupal 11.3.10 Update released for Drupal core (11.3.10)!

Branch Menu

No security coverage
View on drupal.org

A custom Drupal 11 module that renders standard menus as polygonal tree graph using D3.js.

Technical Overview

The Branch Menu module provides a custom block that recursively extracts up to 6 levels of menu links and injects them into a frontend JavaScript environment. The frontend utilizes D3.js to dynamically draw a geometric, downward-flowing tree graph without overlapping nodes.

Features
* **Dynamic Block Configuration:** Select which Drupal menu to render directly from the block layout UI.
* **Polygonal Path Generation:** Overrides standard D3 curves with strict algorithmic rules to create architectural, angular branches (40% to 60% mid-point elbows).
* **Anti-Overlap Logic:** Employs a cascading Y-axis coordinate calculation, ensuring child nodes strictly flow downward and siblings never overlap.
* **Dynamic Typography Placement:** Text anchors automatically flip (left/right) based on the branch direction to prevent intersecting lines.
* **SVG Animations:** Includes hardware-accelerated SVG scaling (`transform-box: fill-box`) and stroke-width transitions on hover.

Architecture

The module is structured as follows:

* `branch_menu.info.yml`: Module declaration and core requirements.
* `branch_menu.libraries.yml`: Dependency management (loads D3.js v7 via CDN and local assets).
* `src/Plugin/Block/BranchMenuBlock.php`: Backend logic to load `MenuLinkTreeInterface`, extract hierarchy, and pass variables to `drupalSettings`.
* `js/branch_menu.js`: Core D3.js logic calculating layout, Bounding Box (viewBox), and SVG paths.
* `js/branch_animations.js`: Event listeners handling non-destructive `mouseenter` and `mouseleave` CSS transitions.
* `css/branch_menu.css`: Base visual styles, crisp-edge rendering, and animation curves.

branch_menu/
├── branch_menu.info.yml
├── branch_menu.libraries.yml
├── branch_menu.module
├── README.md
├── css/
│ └── branch_menu.css
├── js/
│ ├── branch_menu.js
│ └── branch_animations.js
└── src/
└── Plugin/
└── Block/
└── BranchMenuBlock.php

Installation

1. Place the `branch_menu` folder in your project's `web/modules/custom/` directory.
2. Enable the module via Drush (`drush en branch_menu`) or the Extend interface.
3. Navigate to **Structure > Block layout**.
4. Place the **"Branch Menu Graph"** block in your desired region.
5. In the block configuration, select the menu you wish to render.
6. Ensure your selected menu has its parent links set to **"Show as expanded"** to allow deep rendering.

Dependencies

* Drupal Core ^11
* D3.js v7 (Loaded externally via jsDelivr CDN by default)

Activity

Total releases
2
First release
Jul 2026
Latest release
4 hours ago
Release cadence
0 days
Stability
50% stable

Releases

Version Type Release date
1.0.0 Stable Jul 13, 2026
1.0.x-dev Dev Jul 13, 2026