Top Related Projects
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
a super simple, no-nonsense diagramming library written in react that just works
🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
Simple flow library 🖥️🖱️
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
JavaScript framework for visual programming
Quick Overview
MrBlenny/react-flow-chart is a React library for building interactive flowcharts and node-based diagrams. It provides a flexible and customizable solution for creating and manipulating flowcharts in React applications, with features like drag-and-drop functionality, custom node and link rendering, and state management.
Pros
- Highly customizable with support for custom node and link rendering
- Built-in drag-and-drop functionality for easy chart manipulation
- Lightweight and performant, suitable for complex diagrams
- Good documentation and examples for quick start and advanced usage
Cons
- Limited built-in layout algorithms for automatic chart arrangement
- Steeper learning curve compared to some simpler flowchart libraries
- Requires additional styling effort to achieve polished look out-of-the-box
- Some advanced features may require deeper understanding of the library's internals
Code Examples
- Basic flowchart setup:
import { FlowChart } from '@mrblenny/react-flow-chart'
const Chart = () => (
<FlowChart
chart={chartState}
callbacks={callbacks}
/>
)
- Custom node rendering:
const CustomNode = ({ node }) => (
<div style={{ background: 'lightblue', padding: '10px' }}>
<strong>{node.properties.title}</strong>
<p>{node.properties.description}</p>
</div>
)
const Chart = () => (
<FlowChart
chart={chartState}
Components={{
NodeInner: CustomNode,
}}
/>
)
- Adding a new node programmatically:
const addNode = () => {
const newNode = {
id: 'node-' + Date.now(),
type: 'default',
position: { x: 100, y: 100 },
properties: { title: 'New Node' },
}
setChartState({
...chartState,
nodes: {
...chartState.nodes,
[newNode.id]: newNode,
},
})
}
Getting Started
-
Install the package:
npm install @mrblenny/react-flow-chart
-
Import and use the FlowChart component:
import React, { useState } from 'react' import { FlowChart } from '@mrblenny/react-flow-chart' const initialChartState = { offset: { x: 0, y: 0 }, nodes: { node1: { id: 'node1', type: 'default', position: { x: 100, y: 100 }, properties: { title: 'Node 1' } }, node2: { id: 'node2', type: 'default', position: { x: 300, y: 100 }, properties: { title: 'Node 2' } }, }, links: { link1: { id: 'link1', from: { nodeId: 'node1' }, to: { nodeId: 'node2' } }, }, selected: {}, hovered: {}, } const MyFlowChart = () => { const [chartState, setChartState] = useState(initialChartState) return ( <FlowChart chart={chartState} callbacks={{ onNodeClick: (event, node) => console.log('Node clicked:', node), onLinkClick: (event, link) => console.log('Link clicked:', link), }} /> ) } export default MyFlowChart
Competitor Comparisons
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
Pros of xyflow
- More active development and larger community support
- Extensive documentation and examples
- Better TypeScript support and type definitions
Cons of xyflow
- Steeper learning curve due to more complex API
- Potentially higher bundle size due to additional features
Code Comparison
react-flow-chart:
import { FlowChart } from '@mrblenny/react-flow-chart'
<FlowChart
chart={chartSimple}
callbacks={callbacks}
/>
xyflow:
import ReactFlow from 'reactflow'
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
/>
xyflow offers a more modular approach with separate state management for nodes and edges, while react-flow-chart uses a single chart object. xyflow also provides more granular control over interactions and changes to the flow chart.
Both libraries allow for customization of nodes and edges, but xyflow's API is more extensive and flexible. xyflow also includes features like minimap, background patterns, and advanced edge routing out of the box, which are not available in react-flow-chart.
Overall, xyflow is more feature-rich and actively maintained, making it a better choice for complex projects. However, react-flow-chart may be simpler to set up for basic use cases.
a super simple, no-nonsense diagramming library written in react that just works
Pros of react-diagrams
- More mature and feature-rich library with a larger community
- Supports custom node and link types out of the box
- Offers a powerful event system for fine-grained control
Cons of react-diagrams
- Steeper learning curve due to its complexity
- Requires more boilerplate code to set up basic diagrams
- Less intuitive API compared to react-flow-chart
Code Comparison
react-diagrams:
const engine = new DiagramEngine();
engine.installDefaultFactories();
const model = new DiagramModel();
const node1 = new DefaultNodeModel('Node 1', 'rgb(0,192,255)');
node1.setPosition(100, 100);
react-flow-chart:
const chart = {
offset: {
x: 0,
y: 0,
},
nodes: {
node1: {
id: 'node1',
type: 'default',
position: {
x: 100,
y: 100,
},
properties: {
title: 'Node 1',
},
},
},
};
Both libraries offer powerful diagramming capabilities, but react-diagrams provides more advanced features at the cost of complexity, while react-flow-chart offers a simpler API for basic use cases.
🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
Pros of X6
- More comprehensive and feature-rich, offering a wide range of graph editing capabilities
- Better performance for large-scale graphs with thousands of nodes and edges
- Extensive documentation and examples, making it easier to implement complex functionalities
Cons of X6
- Steeper learning curve due to its extensive API and features
- Larger bundle size, which may impact initial load times for web applications
Code Comparison
X6:
import { Graph } from '@antv/x6';
const graph = new Graph({
container: document.getElementById('container'),
width: 800,
height: 600,
});
graph.addNode({ x: 100, y: 100, width: 80, height: 40, label: 'Hello' });
react-flow-chart:
import { FlowChartWithState } from '@mrblenny/react-flow-chart';
const chartSimple = {
offset: { x: 0, y: 0 },
nodes: {
node1: { type: 'output-only', position: { x: 100, y: 100 }, properties: { label: 'Hello' } },
},
links: {},
};
<FlowChartWithState initialValue={chartSimple} />;
Simple flow library 🖥️🖱️
Pros of Drawflow
- Lightweight and dependency-free, making it easier to integrate into various projects
- Supports both mouse and touch events, enhancing usability across devices
- Offers a simple and intuitive API for creating and manipulating nodes and connections
Cons of Drawflow
- Less extensive documentation compared to react-flow-chart
- Fewer built-in features and customization options out of the box
- Limited community support and fewer examples available
Code Comparison
react-flow-chart:
import { FlowChart } from 'react-flow-chart'
const chartSimple = {
offset: {
x: 0,
y: 0,
},
nodes: {
node1: {
id: 'node1',
type: 'output-only',
position: {
x: 300,
y: 100,
},
ports: {
port1: {
id: 'port1',
type: 'output',
properties: {
value: 'yes',
},
},
},
},
},
}
<FlowChart
chart={chartSimple}
callbacks={callbacks}
/>
Drawflow:
import Drawflow from 'drawflow'
const drawflow = new Drawflow(document.getElementById('drawflow'))
drawflow.addNode('github', 1, 1, 150, 100, 'github', {}, 'Github')
drawflow.addNode('telegram', 10, 10, 150, 100, 'telegram', {}, 'Telegram')
drawflow.addConnection(1, 2, 'output_1', 'input_1')
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
Pros of xyflow
- More active development and larger community support
- Extensive documentation and examples
- Better TypeScript support and type definitions
Cons of xyflow
- Steeper learning curve due to more complex API
- Potentially higher bundle size due to additional features
Code Comparison
react-flow-chart:
import { FlowChart } from '@mrblenny/react-flow-chart'
<FlowChart
chart={chartSimple}
callbacks={callbacks}
/>
xyflow:
import ReactFlow from 'reactflow'
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
/>
xyflow offers a more modular approach with separate state management for nodes and edges, while react-flow-chart uses a single chart object. xyflow also provides more granular control over interactions and changes to the flow chart.
Both libraries allow for customization of nodes and edges, but xyflow's API is more extensive and flexible. xyflow also includes features like minimap, background patterns, and advanced edge routing out of the box, which are not available in react-flow-chart.
Overall, xyflow is more feature-rich and actively maintained, making it a better choice for complex projects. However, react-flow-chart may be simpler to set up for basic use cases.
JavaScript framework for visual programming
Pros of Rete
- More versatile and feature-rich, supporting various node types and complex logic
- Better performance for large-scale diagrams with many nodes and connections
- Active development and community support, with regular updates and improvements
Cons of Rete
- Steeper learning curve due to its complexity and extensive API
- Less focused on React integration, potentially requiring more setup for React projects
- Heavier bundle size, which may impact initial load times for web applications
Code Comparison
React Flow Chart:
import { FlowChart } from '@mrblenny/react-flow-chart'
const Chart = () => (
<FlowChart
chart={chartState}
callbacks={callbacks}
/>
)
Rete:
import Rete from "rete";
import ReactRenderPlugin from "rete-react-render-plugin";
const editor = new Rete.NodeEditor("demo@0.1.0", container);
editor.use(ReactRenderPlugin);
Both libraries offer ways to create flow charts and node-based editors, but Rete provides a more powerful and flexible system for complex node-based applications. React Flow Chart is more straightforward and React-focused, making it easier to integrate into React projects but with fewer advanced features. The choice between them depends on the specific requirements of your project, such as complexity, performance needs, and integration preferences.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
React Flow Chart
- Dragabble Nodes and Canvas
- Create curved links between ports
- Custom components for Canvas, Links, Ports, Nodes
- React state container
- Update state on Select/Hover nodes, ports and links
- Base functionality complete
- Stable NPM version
- Scroll/Pinch canvas to zoom
- Ctrl+z/Ctrl+y history
- Read-only mode
- Redux state container
- Arrow heads on links
- Docs
Storybook Demo
CodeSandbox Demo
This project aims to build a highly customisable, declarative flow chart library. Critically, you control the state. Pick from Redux, MobX, React or any other state managment library - simply pass in the current state and hook up the callbacks.
For example:
Data Stucture
The flow chart is designed as a collection of Nodes, Ports and Links. You can specify your own custom properties, making this format quite flexible. See types/chart.ts. Note, nodes, ports and links should have a unique id.
Example
export const chart: IChart = {
offset: {
x: 0,
y: 0,
},
scale: 1,
nodes: {
node1: {
id: 'node1',
type: 'output-only',
position: {
x: 300,
y: 100,
},
ports: {
port1: {
id: 'port1',
type: 'output',
properties: {
value: 'yes',
},
},
port2: {
id: 'port2',
type: 'output',
properties: {
value: 'no',
},
},
},
},
node2: {
id: 'node2',
type: 'input-output',
position: {
x: 300,
y: 300,
},
ports: {
port1: {
id: 'port1',
type: 'input',
},
port2: {
id: 'port2',
type: 'output',
},
},
},
},
links: {
link1: {
id: 'link1',
from: {
nodeId: 'node1',
portId: 'port2',
},
to: {
nodeId: 'node2',
portId: 'port1',
},
},
},
selected: {},
hovered: {},
}
This will produce a simple 2 noded chart which looks like:
Basic Usage
npm i @mrblenny/react-flow-chart
Most components/types are available as a root level export. Check the storybook demo for more examples.
import { FlowChartWithState } from "@mrblenny/react-flow-chart";
const chartSimple = {
offset: {
x: 0,
y: 0
},
nodes: {
node1: {
id: "node1",
type: "output-only",
position: {
x: 300,
y: 100
},
ports: {
port1: {
id: "port1",
type: "output",
properties: {
value: "yes"
}
},
port2: {
id: "port2",
type: "output",
properties: {
value: "no"
}
}
}
},
node2: {
id: "node2",
type: "input-output",
position: {
x: 300,
y: 300
},
ports: {
port1: {
id: "port1",
type: "input"
},
port2: {
id: "port2",
type: "output"
}
}
},
},
links: {
link1: {
id: "link1",
from: {
nodeId: "node1",
portId: "port2"
},
to: {
nodeId: "node2",
portId: "port1"
},
},
},
selected: {},
hovered: {}
};
const Example = (
<FlowChartWithState initialValue={chartSimple} />
);
With Internal State
stories/InternalReactState.tsx
With External State
stories/ExternalReactState.tsx
Readonly Mode
Other Demos
stories/ExternalReactState.tsx
Contributing
If you're interested in helping out, let me know.
In particular, would be great to get a hand with docs and redux / mobx integrations.
Development
npm install
npm run start:storybook
Top Related Projects
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
a super simple, no-nonsense diagramming library written in react that just works
🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
Simple flow library 🖥️🖱️
React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
JavaScript framework for visual programming
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot