a05e39525657f678a1c4818beb35fdf976544126
🌊 React Flow
React library for building node-based graphs.
Installation
npm install github:wbkd/react-flow
Usage
This is a very basic example of how to use react-flow. There are more advanced examples in the example folder.
import React from 'react';
import Graph from 'react-flow';
const elements = [
{ id: '1', data: { label: 'Node 1' }, position: { x: 250, y: 5 } },
{ id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } },
{ id: 'e1-2', source: '1', target: '2', animated: true },
];
const graphStyles = { width: '100%', height: '100%' };
const BasicGraph = () => (
<Graph elements={elements} style={graphStyles} />
);
Props
elements: array with nodes and edgesonElementClick: element click handleronElementsRemove: element remove handleronNodeDragStop: node drag stop handleronConnect: connect handleronLoad: editor load handleronMove: move handlernodeTypes: object with node typesedgeTypes: object with node typesstyle: css style passed to the wrapperconnectionLineType: connection line type =straightorbezierconnectionLineStyle: connection style as svg attributesdeleteKeyCode: default:16selectionKeyCode: default:falseshowBackground: default:truebackgroundGap: gap size - default:16backgroundColor: color of dots or lines - default:#eeebackgroundType: background type =dotsorlines- default:dotssnapToGrid: default:falsesnapGrid: [x, y] array - default:[16, 16]onlyRenderVisibleNodes: default:true
Plugins
- Mini map
- Controls: zoom & fit view
Description
Languages
TypeScript
85.5%
Svelte
11.6%
CSS
2.3%
JavaScript
0.6%