Skip to main content

reflex-xyflow

A Reflex custom component that wraps xyflow / React Flow (@xyflow/react, v12), so you can build node-based UIs — flow charts, diagrams, graphs, pipelines and no-code editors — in pure Python.

Status: alpha (v0.0.1). Core controlled-graph functionality works; see the roadmap.


Features

  • Controlled graph driven entirely from Reflex server state (nodes / edges as plain dicts).
  • Wrapped components: ReactFlow, Background, Controls, MiniMap, Panel, Handle, NodeResizer, NodeToolbar.
  • Rich event surface: change / connect / drag / selection / pane / delete handlers, forwarded as Python event handlers.
  • Pure-Python state reducers (apply_node_changes, apply_edge_changes, add_edge) that mirror React Flow's client-side helpers.
  • Automatic stylesheet injection and React Flow 12 color modes (light / dark / system).

Requirements

Dependency Version
Python >= 3.11 (tested on 3.11 and 3.12)
Reflex >= 0.10.0
@xyflow/react 12.8.6 (pinned, installed automatically by Reflex)
Node.js (only to build the frontend) 24 LTS recommended

Upgrading from 0.0.1: 0.1.0 drops Python 3.10 and requires Reflex 0.10+. Enums are now enum.StrEnum, so str(Position.TOP) returns "top".

Installation

Using uv (recommended):

uv pip install reflex-xyflow

Using pip:

pip install reflex-xyflow

Quick start

import reflex as rx
import reflex_xyflow as xyflow
from reflex_xyflow import add_edge, apply_node_changes, apply_edge_changes


class State(rx.State):
    nodes: list[dict] = [
        {"id": "1", "type": "input", "data": {"label": "Start"}, "position": {"x": 250, "y": 25}},
        {"id": "2", "data": {"label": "Middle"}, "position": {"x": 100, "y": 125}},
        {"id": "3", "type": "output", "data": {"label": "End"}, "position": {"x": 250, "y": 250}},
    ]
    edges: list[dict] = [
        {"id": "e1-2", "source": "1", "target": "2", "animated": True},
        {"id": "e2-3", "source": "2", "target": "3"},
    ]

    @rx.event
    def on_nodes_change(self, changes: list[dict]):
        self.nodes = apply_node_changes(changes, self.nodes)

    @rx.event
    def on_edges_change(self, changes: list[dict]):
        self.edges = apply_edge_changes(changes, self.edges)

    @rx.event
    def on_connect(self, connection: dict):
        self.edges = add_edge(connection, self.edges)


def index() -> rx.Component:
    return rx.box(
        xyflow.react_flow(
            xyflow.background(variant="dots", gap=16),
            xyflow.controls(),
            xyflow.mini_map(zoomable=True, pannable=True),
            nodes=State.nodes,
            edges=State.edges,
            on_nodes_change=State.on_nodes_change,
            on_edges_change=State.on_edges_change,
            on_connect=State.on_connect,
            fit_view=True,
        ),
        width="100vw",
        height="100vh",
    )


app = rx.App()
app.add_page(index)

Sizing: ReactFlow fills its parent (width/height: 100%). Always place it inside a sized container (e.g. a rx.box with an explicit height).

Components

Component Factory Purpose
ReactFlow xyflow.react_flow The canvas; holds nodes, edges and events.
ReactFlowProvider xyflow.react_flow_provider Context for hooks outside the canvas.
Background xyflow.background Dots / lines / cross pattern.
Controls xyflow.controls Zoom / fit-view / lock controls.
MiniMap xyflow.mini_map Overview map.
Panel xyflow.panel Positioned overlay for toolbars.
Handle xyflow.handle Connection point in a custom node.
NodeResizer xyflow.node_resizer Resize handles for a node.
NodeToolbar xyflow.node_toolbar Floating toolbar on a node.

See the specification for the full prop and event catalogue, and the data model for node/edge shapes.

Demo app

A multi-page demo (Overview, Interactive, Backgrounds, Styling) lives in xyflow_demo/:

cd xyflow_demo
uv pip install -e ..        # install the component in editable mode
reflex run

Documentation

Development

This project uses uv. Reproduce the Reflex custom-component layout via reflex component init or work directly in this repo:

uv venv --python 3.12 && source .venv/bin/activate
uv pip install -e ".[dev]"
ruff check . && ruff format --check .
pytest

Releases are published to PyPI automatically by the release workflow when a vX.Y.Z tag is pushed on main — see the publishing guide.

Acknowledgements

License

Apache-2.0 — see LICENSE.

Metadata

Release files for reflex-xyflow 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reflex-xyflow 0.1.0
File Size Uploaded Provenance Actions
reflex_xyflow-0.1.0.tar.gz 26.4 kB Without provenance Details for reflex_xyflow-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reflex-xyflow 0.1.0
File Interpreter ABI Platform Actions
reflex_xyflow-0.1.0-py3-none-any.whl Python 3 none any Details for reflex_xyflow-0.1.0-py3-none-any.whl

Total release size: 47.8 kB

Release files / reflex_xyflow-0.1.0.tar.gz

Download URL reflex_xyflow-0.1.0.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0eb7dcc87fa78004edc519c2d0fc653bf044def38ace07ccc312c918df8a0d5c
BLAKE2b-256 checksum
How to use checksums
eb96cd5e8d9cac6c9eabd79c05c5f7ca51920bb629350dae9025790bbd5141d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / reflex_xyflow-0.1.0-py3-none-any.whl

Download URL reflex_xyflow-0.1.0-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ada7736ad51fd829a41cb39687b78a62117c4d7592c904e234d2bfec89b590ae
BLAKE2b-256 checksum
How to use checksums
a68a68178cab6bf8caafe3283d57388f97b198c0a53113614fbdde09827b7428
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for reflex-xyflow 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page