This is the list of prop types you can pass to the main ReactFlow component.
import ReactFlow from 'react-flow-renderer';
Basic Props
elements: array of nodes and edges (required)style: css propertiesclassName: additional class name
Flow View
minZoom: default: 0.5maxZoom: default: 2defaultZoom: default: 1defaultPosition: default: [0, 0]snapToGrid: default: falsesnapGrid: [x, y] array - default: [15, 15]onlyRenderVisibleElements: default: falsetranslateExtent: default [[-∞, -∞], [+∞, +∞]]nodeExtent: default [[-∞, -∞], [+∞, +∞]] defines the extent for the node positionspreventScrolling: default true if true default browser scroll behaviour is prevented
Event Handlers
onElementClick(event, element): called when user clicks node or edgeonElementsRemove(elements): called when user removes node or edgeonNodeDragStart(event, node): node drag startonNodeDrag(event, node): node dragonNodeDragStop(event, node): node drag stoponNodeMouseEnter(event, node): node mouse enteronNodeMouseMove(event, node): node mouse moveonNodeMouseLeave(event, node): node mouse leaveonNodeContextMenu(event, node): node context menuonNodeDoubleClick(event, node): node double clickonConnect({ source, target }): called when user connects two nodesonConnectStart(event, { nodeId, handleType }): called when user starts to drag connection lineonConnectStop(event): called when user stops to drag connection lineonConnectEnd(event): called after user stops or connects nodesonEdgeUpdate(oldEdge, newConnection): called when the end of an edge gets dragged to another source or targetonEdgeMouseEnter(event, edge): edge mouse enteronEdgeMouseMove(event, edge): edge mouse moveonEdgeMouseLeave(event, edge): edge mouse leaveonEdgeContextMenu(event, edge): called when user does a right-click on an edgeonEdgeUpdateStart(event, edge): called when user starts to update an edgeonEdgeUpdateEnd(event, edge): called when user ends an edge update (for TS users: this is a normal MouseEvent and not a React.MouseEvent like the other ones).onLoad(reactFlowInstance): called after flow is initializedonMove(flowTransform): called when user is panning or zoomingonMoveStart(flowTransform): called when user starts panning or zoomingonMoveEnd(flowTransform): called when user ends panning or zoomingonSelectionChange(elements): called when user selects one or multiple elementsonSelectionDragStart(event, nodes): called when user starts to drag a selectiononSelectionDrag(event, nodes): called when user drags a selectiononSelectionDragStop(event, nodes): called when user stops to drag a selectiononSelectionContextMenu(event, nodes): called when user does a right-click on a selectiononPaneClick(event): called when user clicks directly on the canvasonPaneContextMenu(event): called when user does a right-click on the canvasonPaneScroll(event): called when user scrolls pane (only works when zoomOnScroll is set to `false)
Interaction
nodesDraggable: default: true. This applies to all nodes. You can also change the behavior of a specific node with the draggable node option. If this option is set to false and you have clickable elements inside your node, you need to set pointer-events:all explicitly for these elementsnodesConnectable: default: true. This applies to all nodes. You can also change the behavior of a specific node with the connectable node optionelementsSelectable: default: true. This applies to all elements. You can also change the behavior of a specific node with the selectable node option. If this option is set to false and you have clickable elements inside your node, you need to set pointer-events:all explicitly for these elementszoomOnScroll: default: true. Zoom the graph in and out using the mousewheel or trackpadzoomOnPinch: default: true. Zoom the graph in and out using pinchpanOnScroll: default: false. Move the graph while keeping the zoomlevel using mousewheel or trackpad. Overwrites zoomOnScrollpanOnScrollSpeed: default: 0.5. Controls how fast the canvas is moved while using the mousewheel. Only has an effect if panOnScroll is enabledpanOnScrollMode: default: 'free'. Possible values are 'free' (all directions), 'vertical' (only vertical) or 'horizontal' (only horizontal)zoomOnDoubleClick: default: trueselectNodesOnDrag: default: truepaneMoveable: default: true - If set to false, panning is disabledconnectionMode: default: 'strict'. Possible values are 'strict' (only source to target connections are possible) or 'loose' (source to source and target to target connections are allowed)
Element Customization
nodeTypes: object with node typesedgeTypes: object with edge typesnodeTypesId: if you need to update your nodeTypes, you can pass a unique id here (we will remove this hack in the v10 release)edgeTypesId: if you need to update your edgeTypes, you can pass a unique id here (we will remove this hack in the v10 release)arrowHeadColor: default: #b1b1b7markerEndId: Gets used as the marker-end attribute of the edges
Connection Line Options
connectionLineType: connection line type = default (bezier), straight, step, smoothstep
example usage
import {ConnectionLineType} from 'react-flow-renderer';
<ReactFlow
connectionLineType={ConnectionLineType.Straight}
...
</ReactFlow>
Keys
deleteKeyCode: number | string default: BackspaceselectionKeyCode: number | string default: Shift - While pressing the selectionKeyCode and dragging the mouse you can create a selection for multiple nodes and edgesmultiSelectionKeyCode: number | string default Meta - While pressing the multiSelectionKeyCode you can select multiple nodes and edges with a clickzoomActivationKeyCode: number | string default Meta - While pressing the zoomActivationKeyCode you can zoom even if panOnScroll=true or zoomOnScroll=false
Typescript: The interface of the ReactFlow Prop Types are exported as ReactFlowProps. You can use it in your code as follows:
import { ReactFlowProps } from 'react-flow-renderer';