Skip to content

Feature Request: Allow subgraphs to have different directions than the main graph (e.g., LR inside TD) #6785

@zjy-dev

Description

@zjy-dev

Proposal

Feature Request

🤗🤗

Summary

Currently, Mermaid does not allow subgraphs to have a different direction (e.g. LR, TD, BT, etc.) from the main graph. This limits the flexibility when designing complex diagrams that require nested directional flows.

Motivation

In large systems or workflows, it is common to have a top-down overall structure (TD), but with certain modules or components better represented with left-right (LR) flows.

Example use case:

graph TD
  A --> B
  subgraph Sub
    direction LR
    B1 --> B2 --> B3
  end
  B --> C

Currently, the direction LR inside the subgraph is obviously ignored.

Proposed Solution

Enable direction override within subgraphs. This could follow a syntax like:

subgraph Sub [Sub Module]
  direction LR
  B1 --> B2 --> B3
end

🤗🤗

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions